[Qt-interest] connect fails at type conversion

Matthias Pospiech matthias.pospiech at gmx.de
Mon Apr 20 14:16:02 CEST 2009


At this point

connect(waitThread, SIGNAL(waitFinished()), this, 
SIGNAL(positionReached()));

I get the error

1>.\src\MicroSMCCtrl.cpp(176) : error C2243: 'Typumwandlung': 
Konvertierung von 'MicroSMCCtrlWaitThread *' zu 'const QObject *' ist 
bereits vorhanden, aber es kann nicht darauf zugegriffen werden.


I do not see why.

Here some more code:

void MicroSMCCtrl::WaitForPositionReachedThread(const int & destPos)
{
    if (!waitThread)
        waitThread = new MicroSMCCtrlWaitThread(this);
    else
        waitThread->stop();

    waitThread->WaitForPositionReached(destPos);
    connect(waitThread, SIGNAL(waitFinished()), this, 
SIGNAL(positionReached()));
}


class MicroSMCCtrlWaitThread : QThread
{
public:
    MicroSMCCtrlWaitThread(MicroSMCCtrl * ctrl) : QThread(), 
SMCCtrl(ctrl), m_stopped(false)
    {}
    ~MicroSMCCtrlWaitThread() {}

    void WaitForPositionReached(const int & destPos)
    {
        m_destPos = destPos;
        m_stopped = false;
        start();
    }

    void run()
    {
        int currPos;
        do
        {
            SMCCtrl->getState();
            currPos = SMCCtrl->Position();
            qDebug () << "curr: " << currPos << ", dest: " << m_destPos ;
            delay(100);
        } while ((currPos != m_destPos) && (!m_stopped));
        emit waitFinished();
    }

    void stop()
    {
        m_stopped = true;
    }

signals:
    void waitFinished();

private:
    MicroSMCCtrl * SMCCtrl;
    volatile bool m_stopped;
    int m_destPos;

};


class MicroSMCCtrl : public QObject, public MicroSMCParameters
{
    Q_OBJECT
public:
...
};

Matthias



More information about the Qt-interest-old mailing list