Slots not added in moc file



  • public slots:
    void timeout();
    void doError();
    void retryTimerTimeout();
    void replyReady(QByteArray array);

    the first three aren't added to moc file but last one works correctly!
    what might be the issue??

    class inherited from QObject
    macro is included .


  • Lifetime Qt Champion

    Hi
    It can be stale qmake cache.
    Try to delete build folder and do rebuild all.



  • i used clean build.
    then i manualy delete the build directory! it didnt work as well


  • Lifetime Qt Champion

    @mahd96
    Ok, if you make a default GUI project, and paste those slots to mainwindow and
    their bodies to cpp. Is it still not included?
    It could choke on something but your slots seem perfectly normal.


  • Lifetime Qt Champion

    Hi,

    To add to @mrjj, can you post the complete class declaration ?



  • @mrjj
    no its not GUI project.
    every thing is fine with cpp an header file. Moc file is not being created correctly



  • @SGaist

    QObject::connect(&networkHandler,SIGNAL(replyReady(QByteArray)),this,SLOT(replyReady(QByteArray)));
    QObject::connect(&networkHandler,SIGNAL(error()),this,SLOT(doError()));
    QObject::connect(&networkHandler,SIGNAL(timeout()),this,SLOT(timeout()));

    retryTimer.setInterval(UploadRequest::RetryTimerInterval);
    retryTimer.setSingleShot(true);
    QObject::connect(&retryTimer,SIGNAL(timeout()),this,SLOT(retryTimerTimeout()));
    

    //#######################################################################################
    void UploadExistApi::replyReady(QByteArray array)
    {
    qDebug() << "UploadExistApi::replyReady | replyData: " << array;
    if(!processResult(array))
    {
    doError();
    }
    }
    //#######################################################################################
    void UploadExistApi::timeout()
    {
    qDebug() << "UploadExistApi::timeout";
    currentRequest.setIsTimeOut(true);
    doError();
    }
    //#######################################################################################
    void UploadExistApi::retryTimerTimeout()
    {
    startFileExist(currentRequest);
    }

    //#######################################################################################
    void UploadExistApi::doError()
    {
    if(currentRequest.getTries() >= UploadRequest::MaximumTriesCount)
    {
    qDebug() << "UploadExistApi::startFileExist | Maximum number of tries reached ";
    currentFileInfo.clear();
    currentRequest.clear();
    emit error();
    }
    else
    {
    retryTimer.start();
    }
    }


  • Lifetime Qt Champion

    Hi
    Just to be sure, you are still having a QApplication
    calling a.exec() somewhere ? (in main)
    Also, can you post your .pro file ?


  • Qt Champions 2018

    @mrjj said in Slots not added in moc file:

    Also, can you post your .pro file ?

    And you complete source/header also - where did you define your timer?


  • Qt Champions 2017

    what do you mean by not added ? Is something not working for you ? On what basis are you telling that it is not added ? Did you open the moc_UploadExistingAPi file & verify ? Can you see the time stamp of this file ? If you use those slot, is slot getting called ? I saw that you are creating stack object of retryTimer. Hope the object is still is in scope.

    You said last one is added. First three are added. By chance did some body kept the moc files somewhere else ? If last one is added, first three also should be added.



  • @mrjj @SGaist
    I solved the issue by reinstalling msvc2015

    I recently installed Visual Studio 2017 and i had visual studio2015 in my pc. i think the were some kind of incompibality there that cause this issue.
    i try to reset my windows and make a clean install of Visual studio(i need msvc compiler and windows kits) and it worked


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.