I get the following error:
mainwindow.cpp:168: error: no matching function for call to 'MainWindow::connect(MainWindow*, const char*, MediaPlayer*&, const char*)' QObject::connect(this, SIGNAL(PlayMedia()), _MediaPlayer, SLOT(PlayMedia())); ^
C:\Qt\Qt5.5.0\5.5\mingw492_32\include\QtCore\qobject.h:213: error: no type named 'Object' in 'struct QtPrivate::FunctionPointer'
MediaPlayer Class:
class MediaPlayer : public QObject
{
Q_OBJECT
public:
MediaPlayer();
~MediaPlayer();
public slots:
void OnPlayMedia();
...
void MediaPlayer::OnPlayMedia()
{
qDebug() << "PlayMedia";
}
MainWindow Class:
class MainWindow : public QMainWindow
{
Q_OBJECT
signals:
void PlayMedia();
private:
MediaPlayer *mMediaPlayer;
...
void MainWindow::Initialize()
{
mMediaPlayer = new MediaPlayer();
connect(this, SIGNAL(PlayMedia), mMediaPlayer, SLOT(OnPlayMedia));
...
}
But I get the error everytime I build the project
Update 1: I update the code but I still get the error
update 2 The problem was that MediaPlayer was missing QObject
class MediaPlayer : public QObject
Adding this fixed the code.
_
– user3528438OnPlayMedia
. – user3528438