///playlistmanager.h
class PlaylistsManager
{
public:
PlaylistsManager(QVector<MyMusicPlayer*>);
PlaylistsManager(QString name);
private:
QVector<MyMusicPlayer*> playlist; // same as std::vector;
QString name; // same as std::string
};
///////////////////////on other cpp:
class MainWindow
{
public:
void createNewPlaylist(QString);
private:
QVector<PlaylistsManager> playlists; //same as std::vector;
};
void MainWindow::createNewPlaylist(QString playlist_name)
{
playlists.push_back(playlist_name); // this is where error comes from
}
I might have been wrong with my first post, Im not sure if it calls the default constructor, someone will have to correct me on that. The problem on line 27 is this.
playlist is a Vector of PlaylistManager . in that function, you're pushing back a string, when your vector doesnt take strings, it takes PlayListManager, like this one -
Please post the constructor implementations. And post the complete error message, all of them, exactly as they appear in your development environment. There should probably be several messages related to the message you have posted.
when your vector doesnt take strings, it takes PlayListManager, like this one -
it doesnt take a pointer or a reference to PlaylistsManager object or QString so it should be okay if i call the constructor directly, not sure so correct me if im wrong
here is the screenshot of complete error messages:
Well, that makes it pretty clear. QVector requires a type with a default constructor, and your type doesn't have one. It's an odd design decision for QVector::reallocData to default construct objects, but... there it is.
The values stored in the various containers can be of any assignable data type. To qualify, a type must provide a default constructor, a copy constructor, and an assignment operator. This covers most data types you are likely to want to store in a container, including basic types such as int and double, pointer types, and Qt data types such as QString, QDate, and QTime, but it doesn't cover QObject or any QObject subclass (QWidget, QDialog, QTimer, etc.). If you attempt to instantiate a QList<QWidget>, the compiler will complain that QWidget's copy constructor and assignment operators are disabled. If you want to store these kinds of objects in a container, store them as pointers, for example as QList<QWidget *>.