Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. ui_somedialog.h goes missing after including somedialog.h to test cpp file

ui_somedialog.h goes missing after including somedialog.h to test cpp file

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
22 Posts 4 Posters 3.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PusRob
    wrote on last edited by
    #1

    Hi.

    I have a subdirs project, which contains a MyApp project and a Tests project. Here's the project tree:

    AppProject
        |_AppProject.pro
        |_MyApp
          |_myapp.pro
          |_main.cpp
          |_mainwindow.h
          |_mainwindow.cpp
          |_mainwindow.ui
          |_somedialog.h
          |_somedialog.cpp
          |_somedialog.ui
        |_Tests
          |_tests.pro
          |_main.cpp
          |_tst_somedialog.cpp
    

    If I include somedialog.h to mainwindow.h, the application compiles and everything works. If I include somedialog.h into tst_somedialog.cpp, the compiler says ui_somedialog.h is missing. If I point my cursor in Creator over the "missing" header, the tooltip actually shows its correct location, thus confirming that it exists. Why can't I include it into the test source? Why does it go missing? Here 's the project file for the test:

    QT += testlib
    QT += widgets gui
    
    TARGET = Tests
    TEMPLATE = app
    
    CONFIG += c++14
    CONFIG += testcase 
    CONFIG -= debug_and_release
    
    INCLUDEPATH += ../MyApp
    
    SOURCES += main.cpp \
        tst_somedialog.cpp \
    

    And here's for the project:

    QT += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = MyApp
    TEMPLATE = app
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    CONFIG += c++14
    
    HEADERS += mainwindow.h \
               somedialog.h
    
    SOURCES += main.cpp \
               mainwindow.cpp \
               somedialog.cpp
    
    FORMS +=   mainwindow.ui \
               somedialog.ui
    

    What am I missing? I just can't figure it out. Why can't the compiler find the ui_*.h file if it actually exists?

    Thanks for the help.

    aha_1980A jsulmJ 2 Replies Last reply
    0
    • P PusRob

      Hi.

      I have a subdirs project, which contains a MyApp project and a Tests project. Here's the project tree:

      AppProject
          |_AppProject.pro
          |_MyApp
            |_myapp.pro
            |_main.cpp
            |_mainwindow.h
            |_mainwindow.cpp
            |_mainwindow.ui
            |_somedialog.h
            |_somedialog.cpp
            |_somedialog.ui
          |_Tests
            |_tests.pro
            |_main.cpp
            |_tst_somedialog.cpp
      

      If I include somedialog.h to mainwindow.h, the application compiles and everything works. If I include somedialog.h into tst_somedialog.cpp, the compiler says ui_somedialog.h is missing. If I point my cursor in Creator over the "missing" header, the tooltip actually shows its correct location, thus confirming that it exists. Why can't I include it into the test source? Why does it go missing? Here 's the project file for the test:

      QT += testlib
      QT += widgets gui
      
      TARGET = Tests
      TEMPLATE = app
      
      CONFIG += c++14
      CONFIG += testcase 
      CONFIG -= debug_and_release
      
      INCLUDEPATH += ../MyApp
      
      SOURCES += main.cpp \
          tst_somedialog.cpp \
      

      And here's for the project:

      QT += core gui
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      TARGET = MyApp
      TEMPLATE = app
      
      DEFINES += QT_DEPRECATED_WARNINGS
      
      CONFIG += c++14
      
      HEADERS += mainwindow.h \
                 somedialog.h
      
      SOURCES += main.cpp \
                 mainwindow.cpp \
                 somedialog.cpp
      
      FORMS +=   mainwindow.ui \
                 somedialog.ui
      

      What am I missing? I just can't figure it out. Why can't the compiler find the ui_*.h file if it actually exists?

      Thanks for the help.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      HI @PusRob,

      can you show the compiler command line when compiling the test project?

      And have you set up dependencies in your subproject? Because ui_somedialog.h is generated when compiling MyApp (and thus put in MyApps build directory). Creator generates the ui_xxxx.h in RAM to allow code completion, so that does not prove the file really exists.

      Regards

      Qt has to stay free or it will die.

      P 1 Reply Last reply
      1
      • P PusRob

        Hi.

        I have a subdirs project, which contains a MyApp project and a Tests project. Here's the project tree:

        AppProject
            |_AppProject.pro
            |_MyApp
              |_myapp.pro
              |_main.cpp
              |_mainwindow.h
              |_mainwindow.cpp
              |_mainwindow.ui
              |_somedialog.h
              |_somedialog.cpp
              |_somedialog.ui
            |_Tests
              |_tests.pro
              |_main.cpp
              |_tst_somedialog.cpp
        

        If I include somedialog.h to mainwindow.h, the application compiles and everything works. If I include somedialog.h into tst_somedialog.cpp, the compiler says ui_somedialog.h is missing. If I point my cursor in Creator over the "missing" header, the tooltip actually shows its correct location, thus confirming that it exists. Why can't I include it into the test source? Why does it go missing? Here 's the project file for the test:

        QT += testlib
        QT += widgets gui
        
        TARGET = Tests
        TEMPLATE = app
        
        CONFIG += c++14
        CONFIG += testcase 
        CONFIG -= debug_and_release
        
        INCLUDEPATH += ../MyApp
        
        SOURCES += main.cpp \
            tst_somedialog.cpp \
        

        And here's for the project:

        QT += core gui
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = MyApp
        TEMPLATE = app
        
        DEFINES += QT_DEPRECATED_WARNINGS
        
        CONFIG += c++14
        
        HEADERS += mainwindow.h \
                   somedialog.h
        
        SOURCES += main.cpp \
                   mainwindow.cpp \
                   somedialog.cpp
        
        FORMS +=   mainwindow.ui \
                   somedialog.ui
        

        What am I missing? I just can't figure it out. Why can't the compiler find the ui_*.h file if it actually exists?

        Thanks for the help.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @pusrob Your test pro file is missing FORMS += ...

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        P 1 Reply Last reply
        2
        • jsulmJ jsulm

          @pusrob Your test pro file is missing FORMS += ...

          P Offline
          P Offline
          PusRob
          wrote on last edited by
          #4

          @jsulm Thanks for the suggestion, but adding FORMS to the tests.pro doesn't help. Cleaning the build dir doesn't help either.

          1 Reply Last reply
          0
          • aha_1980A aha_1980

            HI @PusRob,

            can you show the compiler command line when compiling the test project?

            And have you set up dependencies in your subproject? Because ui_somedialog.h is generated when compiling MyApp (and thus put in MyApps build directory). Creator generates the ui_xxxx.h in RAM to allow code completion, so that does not prove the file really exists.

            Regards

            P Offline
            P Offline
            PusRob
            wrote on last edited by PusRob
            #5

            @aha_1980 Thanks for the input, here's the compiler output for the test as requested:

            g++ -c -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"/home/someuser/Programming/AppProject/build-AppProject-Desktop-Debug/Tests"' -I../../AppProject/Tests -I. -I../../AppProject/MyApp  -I../../AppProject/GoogleTest/googletest/googletest/include -I../../AppProject/GoogleTest/googletest/googlemock/include  -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtTest -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib64/qt5/mkspecs/linux-g++ -o main.o ../../AppProject/Tests/main.cpp
            
            g++ -pipe -g -std=gnu++1y -Wall -W -dM -E -o moc_predefs.h /usr/lib64/qt5/mkspecs/features/data/dummy.cpp
            /usr/lib64/qt5/bin/moc -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"/home/someuser/Programming/AppProject/build-AppProject-Desktop-Debug/Tests"' --include /home/someuser/Programming/AppProject/build-AppProject-Desktop-Debug/Tests/moc_predefs.h -I/usr/lib64/qt5/mkspecs/linux-g++ -I/home/someuser/Programming/AppProject/Tests -I/home/someuser/Programming/AppProject/MyApp -I/home/someuser/Programming/AppProject/GoogleTest/googletest/googletest/include -I/home/someuser/Programming/AppProject/GoogleTest/googletest/googlemock/include -I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtTest -I/usr/include/qt5/QtCore -I. -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8 -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/x86_64-pc-linux-gnu -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed -I/usr/include ../../AppProject/Tests/tst_somedialog.cpp -o tst_somedialog.moc
            g++ -c -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"/home/someuser/Programming/AppProject/build-AppProject-Desktop-Debug/Tests"' -I../../AppProject/Tests -I. -I../../AppProject/MyApp  -I../../AppProject/GoogleTest/googletest/googletest/include -I../../AppProject/GoogleTest/googletest/googlemock/include  -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtTest -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib64/qt5/mkspecs/linux-g++ -o tst_somedialog.o ../../AppProject/Tests/tst_somedialog.cpp
            In file included from ../../AppProject/Tests/tst_somedialog.cpp:3:
            ../../AppProject/MyApp/somedialog.h:4:10: fatal error: ui_somedialog.h: No such file or directory
             #include "ui_somedialog.h"
                      ^~~~~~~~~~~~~~~~~~~~~
            compilation terminated.
            make: *** [Makefile:889: tst_somedialog.o] Error 1
            

            If I check the ui_xxxx.h file in the build folder, it is there.
            Adding "Tests.depends = MyApp" to the master AppProject.pro file doesn't help either.

            aha_1980A 1 Reply Last reply
            0
            • P PusRob

              @aha_1980 Thanks for the input, here's the compiler output for the test as requested:

              g++ -c -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"/home/someuser/Programming/AppProject/build-AppProject-Desktop-Debug/Tests"' -I../../AppProject/Tests -I. -I../../AppProject/MyApp  -I../../AppProject/GoogleTest/googletest/googletest/include -I../../AppProject/GoogleTest/googletest/googlemock/include  -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtTest -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib64/qt5/mkspecs/linux-g++ -o main.o ../../AppProject/Tests/main.cpp
              
              g++ -pipe -g -std=gnu++1y -Wall -W -dM -E -o moc_predefs.h /usr/lib64/qt5/mkspecs/features/data/dummy.cpp
              /usr/lib64/qt5/bin/moc -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"/home/someuser/Programming/AppProject/build-AppProject-Desktop-Debug/Tests"' --include /home/someuser/Programming/AppProject/build-AppProject-Desktop-Debug/Tests/moc_predefs.h -I/usr/lib64/qt5/mkspecs/linux-g++ -I/home/someuser/Programming/AppProject/Tests -I/home/someuser/Programming/AppProject/MyApp -I/home/someuser/Programming/AppProject/GoogleTest/googletest/googletest/include -I/home/someuser/Programming/AppProject/GoogleTest/googletest/googlemock/include -I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtTest -I/usr/include/qt5/QtCore -I. -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8 -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/x86_64-pc-linux-gnu -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed -I/usr/include ../../AppProject/Tests/tst_somedialog.cpp -o tst_somedialog.moc
              g++ -c -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"/home/someuser/Programming/AppProject/build-AppProject-Desktop-Debug/Tests"' -I../../AppProject/Tests -I. -I../../AppProject/MyApp  -I../../AppProject/GoogleTest/googletest/googletest/include -I../../AppProject/GoogleTest/googletest/googlemock/include  -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtTest -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib64/qt5/mkspecs/linux-g++ -o tst_somedialog.o ../../AppProject/Tests/tst_somedialog.cpp
              In file included from ../../AppProject/Tests/tst_somedialog.cpp:3:
              ../../AppProject/MyApp/somedialog.h:4:10: fatal error: ui_somedialog.h: No such file or directory
               #include "ui_somedialog.h"
                        ^~~~~~~~~~~~~~~~~~~~~
              compilation terminated.
              make: *** [Makefile:889: tst_somedialog.o] Error 1
              

              If I check the ui_xxxx.h file in the build folder, it is there.
              Adding "Tests.depends = MyApp" to the master AppProject.pro file doesn't help either.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @pusrob said in ui_somedialog.h goes missing after including somedialog.h to test cpp file:

              If I check the ui_xxxx.h file in the build folder, it is there.

              Yeah, if I get it correctly, the include directives only point to the source directories, but not the build dirs.

              I'll need to make up my mind about that, that's probably a situation that is not thought like that.

              Usually you have a library that you test or you compile the classes again for the test. But in your case it's a bit distributed, and I have no quick idea how to solve that.

              Regards

              Qt has to stay free or it will die.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                In such a case, the project can be:

                • library
                • app
                • tests

                The library contains all the elements that will be tested and the app just assembles the bits needed.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                P 1 Reply Last reply
                1
                • SGaistS SGaist

                  Hi,

                  In such a case, the project can be:

                  • library
                  • app
                  • tests

                  The library contains all the elements that will be tested and the app just assembles the bits needed.

                  P Offline
                  P Offline
                  PusRob
                  wrote on last edited by
                  #8

                  @sgaist Thanks for the suggestion, but the library version will not work either, as it generates the exact same error. Here's a stackoverflow post describing the exact setup and related source code.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by SGaist
                    #9

                    My bad, I see the issue now...

                    So in fact you need to either add the shadow build folder (using OUT_PWD) to INCLUDEPATH or force the generated file to be put in the sources.

                    As @aha_1980 wrote below, this is wrong. The correct way to do that is to forward declare your UI element in your header and then include the generate header in your .cpp file. So it won't "leak" anywhere else.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    aha_1980A P SGaistS 3 Replies Last reply
                    1
                    • SGaistS SGaist

                      My bad, I see the issue now...

                      So in fact you need to either add the shadow build folder (using OUT_PWD) to INCLUDEPATH or force the generated file to be put in the sources.

                      As @aha_1980 wrote below, this is wrong. The correct way to do that is to forward declare your UI element in your header and then include the generate header in your .cpp file. So it won't "leak" anywhere else.

                      aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @sgaist

                      or force the generated file to be put in the sources.

                      please not. that will create more problems than it solves.

                      Put it the other way round, don't expose internal details. The ui_xxx.h is such a detail that should not appear in a header used by someone else (like the test).

                      Regards

                      Qt has to stay free or it will die.

                      1 Reply Last reply
                      2
                      • SGaistS SGaist

                        My bad, I see the issue now...

                        So in fact you need to either add the shadow build folder (using OUT_PWD) to INCLUDEPATH or force the generated file to be put in the sources.

                        As @aha_1980 wrote below, this is wrong. The correct way to do that is to forward declare your UI element in your header and then include the generate header in your .cpp file. So it won't "leak" anywhere else.

                        P Offline
                        P Offline
                        PusRob
                        wrote on last edited by PusRob
                        #11

                        @sgaist Thanks again for your time and suggestions, but I already tried adding OUT_PWD to INCLUDEPATH before posting any thread anywhere, and unfortunately that doesn't help either. That is why I posted to two forums, because I truly believe I ran out of options. I'm starting to think this is a bug or omission somewhere in qmake, as there is no rational reason (that I can think of) why this shouldn't work with the presented solutions/setup.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @PusRob Please re-read my last message, I've corrected it following @aha_1980's good remark.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          P 1 Reply Last reply
                          1
                          • SGaistS SGaist

                            @PusRob Please re-read my last message, I've corrected it following @aha_1980's good remark.

                            P Offline
                            P Offline
                            PusRob
                            wrote on last edited by
                            #13

                            @sgaist I'd love to, but it would seem your changes to your post got lost somehow. Could you post it again, please?
                            And this is an open question to the board: What do you think is the best way to hide the ui_xxx.h file? Unfortunately I'm not all that experienced with this stuff. Thanks guys.

                            1 Reply Last reply
                            0
                            • SGaistS SGaist

                              My bad, I see the issue now...

                              So in fact you need to either add the shadow build folder (using OUT_PWD) to INCLUDEPATH or force the generated file to be put in the sources.

                              As @aha_1980 wrote below, this is wrong. The correct way to do that is to forward declare your UI element in your header and then include the generate header in your .cpp file. So it won't "leak" anywhere else.

                              SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              Quoting the interesting bits:

                              @sgaist said in ui_somedialog.h goes missing after including somedialog.h to test cpp file:

                              As @aha_1980 wrote below, this is wrong. The correct way to do that is to forward declare your UI element in your header and then include the generate header in your .cpp file. So it won't "leak" anywhere else.

                              See the Notepad tutorial and associated code, it shows that technique I wrote about.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              P 1 Reply Last reply
                              3
                              • SGaistS SGaist

                                Quoting the interesting bits:

                                @sgaist said in ui_somedialog.h goes missing after including somedialog.h to test cpp file:

                                As @aha_1980 wrote below, this is wrong. The correct way to do that is to forward declare your UI element in your header and then include the generate header in your .cpp file. So it won't "leak" anywhere else.

                                See the Notepad tutorial and associated code, it shows that technique I wrote about.

                                P Offline
                                P Offline
                                PusRob
                                wrote on last edited by PusRob
                                #15

                                @sgaist OK, I tried your suggestion as the notepad tutorial showed, and the missing ui_xxx.h file error is gone. Now I get

                                error: undefined reference to `vtable for SomeDialog'
                                

                                for the somedialog.h file and a similar error

                                error: undefined reference to `SomeDialog::SomeDialog(QWidget*)'
                                

                                for the tst_somedialog.cpp file, when I try to default construct an instance.
                                Any ideas how to fix that? Thanks.

                                P.S.: I already tried rerunning qmake and deleting the build folder, it didn't work.

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  Can you show the declaration of your SomeDialog class ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  P 1 Reply Last reply
                                  1
                                  • SGaistS SGaist

                                    Can you show the declaration of your SomeDialog class ?

                                    P Offline
                                    P Offline
                                    PusRob
                                    wrote on last edited by
                                    #17

                                    @sgaist Sure thing, here it is: somedialog.h

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      Might be a silly question but did you properly implement the constructor ? I just realized the corresponding symbol is not found.

                                      If you did so then are you sure that the .cpp file is compiled ?

                                      Check your SOURCES variable. Especially if you put one file per line, you might be missing a backslash.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      P 1 Reply Last reply
                                      1
                                      • SGaistS SGaist

                                        Might be a silly question but did you properly implement the constructor ? I just realized the corresponding symbol is not found.

                                        If you did so then are you sure that the .cpp file is compiled ?

                                        Check your SOURCES variable. Especially if you put one file per line, you might be missing a backslash.

                                        P Offline
                                        P Offline
                                        PusRob
                                        wrote on last edited by
                                        #19

                                        @sgaist The constructor is fine, as I am able to use the class normally in the MyApp project. The problems only start to occur if I want to use the SomeDialog class in the test project as well. Anyway, I tried to add somedialog.cpp to the SOURCES variable just in case, but then I'm back to square one: the compiler reports that ui_xxx.h is missing.

                                        Also, as far as I know, adding class files to SOURCES and HEADERS in the test .pro file is unnecessary, as non-GUI classes tested with GTest do not require it. In this very same project I have dozens of such tests and all of them work just fine without further additions to SOURCES or HEADERS. I guess the problem lies in how MOC and UIC generated files are treated by qmake.

                                        Finally, if I check the build folder, the moc_somedialog.cpp gets generated, though the object file is missing (probably because of the aforementioned errors).

                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          Did you modify the project as I suggested to have a library so you can link your tests and your application against it ?

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          P 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved