Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] missing binary operator before token "(" - QT Creator



  • I'm getting this error in all ui_xxx.h header files( for instance, ui_editwindow.h ) on every line containing #if QT_CONFIG(tooltip).
    I'm also getting the same error in all xxx.cpp files (for instance, editwindow.cpp) on the line where I include the relevant ui_xxx.h header file (for instance, #include ui_editwindow.h in editwindow.cpp)

    In all ui_xxx.h files, the errors are inside of void retranslateUi, so probably it has something to do with translation error (not sure tho).
    The project was initially written in older version of QT(4.x or even older) and now I'm using 5.6.0.(the only version I can use for some reasons..)

    This is my code:
    y.png

    I've seen people with same error saying that it was caused by the name of the header file, or some small mistake inside of the header file. But, in my case, the error is inside ui_editwindow.h, which is automatically built by by QT Creator, and isn't supposed to be edited directly. So, I suppose it's QT Creator bug (as opposed to developer mistake)

    Any ideas about the problem?


  • Lifetime Qt Champion

    @jellyv said in missing binary operator before token "(" - QT Creator:

    The code was initially written over a decade ago and many people have worked on it since, but I know that it ran successfully on some QT 5.x version.

    Please find out which Qt 5.x version that was exactly. It may have been a newer version than 5.6, which could leave unsupported properties in the ui file.

    Have you made sure that all these generated headers are fresh generated by the Qt5 uic?

    I do not think so, could you tell me how can I ensure that QT5 does that?

    Close Qt Creator, delete the build folder(s), the .pro.user, and anything related to Makefile.*, ui_*.h etc. which is surely no source or header file.

    Then open Creator, assign the Qt 5.6 kit to your project and retry.

    If that does not help: can you upload the editwindow.ui file?

    QT Creator 5.6.0

    That is the Qt version, not the Qt Creator version, which you can find on Help > About Qt Creator.

    Regards


  • Lifetime Qt Champion

    Hi @jellyv,

    The basic questions are:

    • which platform are you on?
    • which Qt Creator version, Qt version and compiler are you using?
    • do you get these errors while compiling or while editing/reading code?

    Now the more advanced ones:

    • did the project compile successfully on the latest Qt 4.8.x release?
    • did you already change something to port to Qt 5?
    • Have you made sure that all these generated headers are fresh generated by the Qt5 uic?

    Regards



  • Hi @aha_1980,
    I'm on windows 10 pro (64 bit), and am using QT Creator 5.6.0 (downloaded from the following link: https://download.qt.io/archive/qt/5.6/5.6.0/ . I downloaded qt-opensource-windows-x86-mingw492-5.6.0.exe, which i guess comes with in-built mingw compiler).
    I'm getting the errors while building/compiling the code.

    About the last three questions:

    • did the project compile successfully on the latest Qt 4.8.x release?
      The code was initially written over a decade ago and many people have worked on it since, but I know that it ran successfully on some QT 5.x version.

    • did you already change something to port to Qt 5?
      I haven't made any changes to the code yet (If that's what you're asking)

    • Have you made sure that all these generated headers are fresh generated by the Qt5 uic?
      I do not think so, could you tell me how can I ensure that QT5 does that?


  • Lifetime Qt Champion

    @jellyv said in missing binary operator before token "(" - QT Creator:

    The code was initially written over a decade ago and many people have worked on it since, but I know that it ran successfully on some QT 5.x version.

    Please find out which Qt 5.x version that was exactly. It may have been a newer version than 5.6, which could leave unsupported properties in the ui file.

    Have you made sure that all these generated headers are fresh generated by the Qt5 uic?

    I do not think so, could you tell me how can I ensure that QT5 does that?

    Close Qt Creator, delete the build folder(s), the .pro.user, and anything related to Makefile.*, ui_*.h etc. which is surely no source or header file.

    Then open Creator, assign the Qt 5.6 kit to your project and retry.

    If that does not help: can you upload the editwindow.ui file?

    QT Creator 5.6.0

    That is the Qt version, not the Qt Creator version, which you can find on Help > About Qt Creator.

    Regards



  • This is a long shot but I'll go for it: in editwindow.h did you forget the ; at the end of the class definition?

    class EditWindow{
    
    }
    ; // This guy!
    


  • @VRonin

    namespace Ui {
    class EditWindow;
    }
    

    This is what class definition looks like. the semicolon ( ; ) doesn't have to be after closing bracket ( } ), does it?



  • @aha_1980
    you were right: The generated headers (ui_*.h) were not generated by the QT5 uic. your steps fixed the problem. Amazing, thank you.

    For others who have the same issue in future:
    After I deleted the files listed by @aha_1980, I opened qt and chose Rebuild All, which resulted in some other error.
    I tried the whole thing again(deleted the listed files from original project), and then tried to Clean All, then Build All, and it worked that time. This is because these two processes function differently.

    JboKH.png

    Image credits: Shivprasad Koirala


Log in to reply