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

How to compile source code of QtPropertyBrowser by VS2019 correctly?



  • Thanks for your time.
    I created a QT widget application by VS wizard (sln managed), then i copied source code from "Qt\5.15.0\Src\qttools\src\shared\qtpropertybrowser" to my project.
    When i compiled it, errors happeded, like below:

    1>E:\QtPropertyBrowserDemo\QtPropertyBrowserDemo\x64\Debug\moc\moc_qtbuttonpropertybrowser.cpp(94,29): error C2027: use of undefined type 'QtButtonPropertyBrowserPrivate'
    1>E:\QtPropertyBrowserDemo\QtPropertyBrowserDemo\qtpropertybrowser\qtbuttonpropertybrowser.h(47): message : see declaration of 'QtButtonPropertyBrowserPrivate'
    1>E:\QtPropertyBrowserDemo\QtPropertyBrowserDemo\x64\Debug\moc\moc_qtbuttonpropertybrowser.cpp(95,29): error C2027: use of undefined type 'QtButtonPropertyBrowserPrivate'
    1>E:\QtPropertyBrowserDemo\QtPropertyBrowserDemo\qtpropertybrowser\qtbuttonpropertybrowser.h(47): message : see declaration of 'QtButtonPropertyBrowserPrivate'
    1>E:\QtPropertyBrowserDemo\QtPropertyBrowserDemo\x64\Debug\moc\moc_qtbuttonpropertybrowser.cpp(96,29): error C2027: use of undefined type 'QtButtonPropertyBrowserPrivate'
    1>E:\QtPropertyBrowserDemo\QtPropertyBrowserDemo\qtpropertybrowser\qtbuttonpropertybrowser.h(47): message : see declaration of 'QtButtonPropertyBrowserPrivate'
    1>E:\QtPropertyBrowserDemo\QtPropertyBrowserDemo\x64\Debug\moc\moc_qtpropertybrowser.cpp(377,29): error C2027: use of undefined type 'QtAbstractPropertyBrowserPrivate'
    

    its a long error list, so i just paste some here.

    I tried ervery way i can think of, like use precompiled headers, compare my project with qttools/designer, but i still cannot find the
    problem.

    So anyone can help me out? I commited my project on GitHub, you can pull it if you wish.

    Address is here: https://github.com/LiangZuoting/QtPropertyBrowserDemo


  • Moderators

    Hi, welcome to the forum.

    The problem is your project is set up to compile the generated moc_XXX.cpp files for the qtpropertybrowser headers .
    In this case they are included at the end of qtXXX.cpp files and are not meant to be compiled separately, as they make use of the private implementation in the ccp.

    To fix this, in VS, select all the qtXXX.h files from qtpropertybrowser (except for the qtXXX_p.h). Right click and select Properties.
    In the property page go to Configuration Properties -> Qt Meta-Object-Compiler -> moc and set Dynamic C++ Source to Disable. This will exclude generated moc_ files from direct compilation. They will be compiled as an include in the cpp files from qtpropertybrowser, the way they were meant to be.


  • Moderators

    Hi, welcome to the forum.

    The problem is your project is set up to compile the generated moc_XXX.cpp files for the qtpropertybrowser headers .
    In this case they are included at the end of qtXXX.cpp files and are not meant to be compiled separately, as they make use of the private implementation in the ccp.

    To fix this, in VS, select all the qtXXX.h files from qtpropertybrowser (except for the qtXXX_p.h). Right click and select Properties.
    In the property page go to Configuration Properties -> Qt Meta-Object-Compiler -> moc and set Dynamic C++ Source to Disable. This will exclude generated moc_ files from direct compilation. They will be compiled as an include in the cpp files from qtpropertybrowser, the way they were meant to be.



  • @Chris-Kawa cooooool, you saved me! thanks a lot.


Log in to reply