0
votes

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.

2
Never create any symbol with leading _user3528438
And the slot name is OnPlayMedia.user3528438
I changed it to mMediaPlayer and I get the same erroradviner
Thanks for the help but I still get the error btw C# _aField is used for private fields which I'm originating fromadviner

2 Answers

0
votes

My problem was my class MediaPlayer was missing inheritance of QObject. I updated my original code above to show this

0
votes

MediaPlayer should be derived from QObject:

class MediaPlayer : public QObject
{
    Q_OBJECT

public:
    MediaPlayer(QObject* parent=0):QObject(parent){/* your init here*/}
    ~MediaPlayer();


public slots:
    void OnPlayMedia();
};