Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QT5 and QT6 projects issues with QWidget and QMainWindow
Forum Updated to NodeBB v4.3 + New Features

QT5 and QT6 projects issues with QWidget and QMainWindow

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
18 Posts 5 Posters 2.0k Views
  • 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.
  • F Offline
    F Offline
    Fikrat
    wrote on 1 Feb 2023, 17:00 last edited by
    #1

    I have installed different version of qt such as qt5 and qt6 on ubuntu20.04.05, after that I tried to open simple project based on QWidget and QMainWindow, howevver, while building, it provides an error, telling that QWidget and QMainWindow is not found! Could you please support me?

    C 1 Reply Last reply 1 Feb 2023, 17:06
    0
    • F Fikrat
      1 Feb 2023, 17:00

      I have installed different version of qt such as qt5 and qt6 on ubuntu20.04.05, after that I tried to open simple project based on QWidget and QMainWindow, howevver, while building, it provides an error, telling that QWidget and QMainWindow is not found! Could you please support me?

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 1 Feb 2023, 17:06 last edited by
      #2

      @Fikrat said in QT5 and QT6 projects issues with QWidget and QMainWindow:

      , telling that QWidget and QMainWindow is not found!

      Do you mean the compiler complains that it cant find the headers?
      If so - how did you set up your project? With qmake or cmake? Did you also install the Qt development packages?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fikrat
        wrote on 1 Feb 2023, 17:14 last edited by Fikrat 2 Jan 2023, 17:14
        #3

        Thanks for your fast reply. I installed qt5 and qt6, in the different times to check which version will not provide compilation error. But I faced same error in both versions.I practically installed qt version with help of qt-unified-linux-x64-4.5.1-online.run which is in fact downloaded from qt.io website.
        I did not face this error on ubuntu 18.04

        Please let me know

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JoeCFD
          wrote on 1 Feb 2023, 17:26 last edited by JoeCFD 2 Jan 2023, 17:29
          #4

          I guess the default installation dir is /opt/Qt for Qt5 on Ubuntu and therefore qmake path is not available automatically. You have to set qmake path in your shell. If you use qtcreator, it may be able to detect it.

          On 18.04 you might use installed qt which comes with ubuntu distribution.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Fikrat
            wrote on 1 Feb 2023, 17:30 last edited by
            #5

            Default installation is ~/Qt which is not located in root. I am using cmake in fact. As well as using qt creator, qt creator is not able to detect it.Actually in this case, should i again mention the path in cmake?

            I need to install qt5 on ubuntu 20.04, not on ubuntu 18.04

            J 1 Reply Last reply 1 Feb 2023, 17:38
            0
            • F Fikrat
              1 Feb 2023, 17:30

              Default installation is ~/Qt which is not located in root. I am using cmake in fact. As well as using qt creator, qt creator is not able to detect it.Actually in this case, should i again mention the path in cmake?

              I need to install qt5 on ubuntu 20.04, not on ubuntu 18.04

              J Offline
              J Offline
              JoeCFD
              wrote on 1 Feb 2023, 17:38 last edited by
              #6

              @Fikrat ~/Qt is user name dependent. It is better to install it under /opt/.
              https://github.com/KDAB/GammaRay/issues/213

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Fikrat
                wrote on 1 Feb 2023, 17:42 last edited by
                #7

                thanks so much i will do the same .In any case, I will let you know

                J 1 Reply Last reply 2 Feb 2023, 06:31
                0
                • F Fikrat
                  1 Feb 2023, 17:42

                  thanks so much i will do the same .In any case, I will let you know

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 2 Feb 2023, 06:31 last edited by
                  #8

                  @Fikrat Do you have

                  find_package(Qt6 REQUIRED COMPONENTS Widgets)
                  target_link_libraries(mytarget PRIVATE Qt6::Widgets)
                  

                  in your CMakeList.txt file as shown in https://doc.qt.io/qt-6/qwidget.html ?

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

                  F 1 Reply Last reply 2 Feb 2023, 08:28
                  0
                  • J jsulm
                    2 Feb 2023, 06:31

                    @Fikrat Do you have

                    find_package(Qt6 REQUIRED COMPONENTS Widgets)
                    target_link_libraries(mytarget PRIVATE Qt6::Widgets)
                    

                    in your CMakeList.txt file as shown in https://doc.qt.io/qt-6/qwidget.html ?

                    F Offline
                    F Offline
                    Fikrat
                    wrote on 2 Feb 2023, 08:28 last edited by Fikrat 2 Feb 2023, 08:28
                    #9

                    @jsulm I installed qt5 on directory as the following: /opt/Qt

                    Accordingly, I opened new widget and I controlled CMakeLists.txt which looks like as shown in the image!Qt Cmake.png

                    As you can see, project and its files are highlighed as the white blank as well as include packages in the source files, provided compilation error.

                    J 1 Reply Last reply 2 Feb 2023, 08:53
                    0
                    • F Fikrat
                      2 Feb 2023, 08:28

                      @jsulm I installed qt5 on directory as the following: /opt/Qt

                      Accordingly, I opened new widget and I controlled CMakeLists.txt which looks like as shown in the image!Qt Cmake.png

                      As you can see, project and its files are highlighed as the white blank as well as include packages in the source files, provided compilation error.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 2 Feb 2023, 08:53 last edited by
                      #10

                      @Fikrat So, did you run CMake?

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

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        Fikrat
                        wrote on 2 Feb 2023, 09:05 last edited by
                        #11

                        Dear @jsulm, when I actually build it, but it provided tons of compilation errors as following

                        errors.png

                        J 1 Reply Last reply 2 Feb 2023, 12:22
                        0
                        • F Fikrat
                          2 Feb 2023, 09:05

                          Dear @jsulm, when I actually build it, but it provided tons of compilation errors as following

                          errors.png

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 2 Feb 2023, 12:22 last edited by
                          #12

                          @Fikrat said in QT5 and QT6 projects issues with QWidget and QMainWindow:

                          compilation errors

                          It looks rather like errors from code modelling.
                          Did you actually try to build?

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

                          F 1 Reply Last reply 2 Feb 2023, 15:00
                          1
                          • J jsulm
                            2 Feb 2023, 12:22

                            @Fikrat said in QT5 and QT6 projects issues with QWidget and QMainWindow:

                            compilation errors

                            It looks rather like errors from code modelling.
                            Did you actually try to build?

                            F Offline
                            F Offline
                            Fikrat
                            wrote on 2 Feb 2023, 15:00 last edited by
                            #13

                            Dear @jsulm, I tried to build, though, did not provide any successful build operation. This is very strange. I am completely stacked.

                            J JonBJ 2 Replies Last reply 2 Feb 2023, 15:03
                            0
                            • F Fikrat
                              2 Feb 2023, 15:00

                              Dear @jsulm, I tried to build, though, did not provide any successful build operation. This is very strange. I am completely stacked.

                              J Offline
                              J Offline
                              JoeCFD
                              wrote on 2 Feb 2023, 15:03 last edited by JoeCFD 2 Feb 2023, 15:05
                              #14

                              @Fikrat show output:
                              which qmake

                              Are you using qtcreator?

                              1 Reply Last reply
                              0
                              • F Fikrat
                                2 Feb 2023, 15:00

                                Dear @jsulm, I tried to build, though, did not provide any successful build operation. This is very strange. I am completely stacked.

                                JonBJ Online
                                JonBJ Online
                                JonB
                                wrote on 2 Feb 2023, 15:06 last edited by
                                #15

                                @Fikrat
                                Show the Build Output errors. The only one that matters is the first one where it can't find <QObject>.

                                I need to install qt5 on ubuntu 20.04, not on ubuntu 18.04

                                You realize that Ubuntu release supplies a pre-built package for Qt5? But not sure why you want both Qt5 & Qt6. Plus Qt5 was designed for qmake rather than cmake.

                                J 1 Reply Last reply 2 Feb 2023, 15:09
                                0
                                • JonBJ JonB
                                  2 Feb 2023, 15:06

                                  @Fikrat
                                  Show the Build Output errors. The only one that matters is the first one where it can't find <QObject>.

                                  I need to install qt5 on ubuntu 20.04, not on ubuntu 18.04

                                  You realize that Ubuntu release supplies a pre-built package for Qt5? But not sure why you want both Qt5 & Qt6. Plus Qt5 was designed for qmake rather than cmake.

                                  J Offline
                                  J Offline
                                  JoeCFD
                                  wrote on 2 Feb 2023, 15:09 last edited by
                                  #16

                                  @JonB I do not see any problem to use cmake for Qt5. I Have both cmake and qmake for Qt5. I guess cmake is preferred for Qt6. But I still test some Qt6 cases with qmake.

                                  JonBJ 1 Reply Last reply 2 Feb 2023, 18:45
                                  0
                                  • C Offline
                                    C Offline
                                    Christian Ehrlicher
                                    Lifetime Qt Champion
                                    wrote on 2 Feb 2023, 17:38 last edited by
                                    #17

                                    When QtCreator shows files grayed out then the cmake/qmake configure run did not work out and the error was written to the configure output panel - look at it, fix the errors and run again. QtCreator will not do any code model things when the project is not configured correctly.

                                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                    Visit the Qt Academy at https://academy.qt.io/catalog

                                    1 Reply Last reply
                                    0
                                    • J JoeCFD
                                      2 Feb 2023, 15:09

                                      @JonB I do not see any problem to use cmake for Qt5. I Have both cmake and qmake for Qt5. I guess cmake is preferred for Qt6. But I still test some Qt6 cases with qmake.

                                      JonBJ Online
                                      JonBJ Online
                                      JonB
                                      wrote on 2 Feb 2023, 18:45 last edited by
                                      #18

                                      @JoeCFD
                                      I meant for example all the sample code etc. I have seen out there for Qt5 is for qmake and .pro files. And the OP seems to be getting into some difficulty. But you know more than I in this area.

                                      1 Reply Last reply
                                      0

                                      1/18

                                      1 Feb 2023, 17:00

                                      • Login

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