QT5 and QT6 projects issues with QWidget and QMainWindow
-
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?
-
@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? -
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.04Please let me know
-
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.
-
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
-
@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 ?
-
@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!
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.
-
@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? -
@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.
-
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.