Problem with QMain Window
-
Hello,
I have a problem with qt project. I try to build project that was created in 2008, but I encounter a problem with QMainWindow I think, I have 11 errors, but I think that they all reffers to that one problem. Unfortunately, I don't know what can be wrong. Can you help me?#ifndef _SERVICESCOMPONENT_H_ #define _SERVICESCOMPONENT_H_ #include <commons.h> //#include <QtGui> //#include <QtWidgets> #include <QtWidgets/qwidget.h> #include <QtCore/qmutex.h> #include <QtWidgets/qtreeview.h> #include <QtWidgets/qheaderview.h> #include <QtWidgets/qtreewidget.h> #include <map> #include <set> #include "DCSCmd.h" //#include <QtWidgets/qmainwindow.h> #include <QtCore/qobject.h> class ServicesComponent : public QMainWindow { }
many of errors reffers to moc_[files] but I don't understand whyWhen I add #include <QtWidgets/qmainwindow.h> I get 700 errors, which every one of them is like unresolved external ...
But I had such include in other files, and there are no problem with it. In .pro file I added += widgets.
I don't have more idea what can help in my situation.
Thanks for all suggestions. -
Hi
Unless you are using a super old Qt then its just
#include <QMainWindow>also, make SURE no moc__ files are in the project folder. They are generated and should live in the build folder.
If it find old moc__ files, odd stuff will happen :) -
Hi
Unless you are using a super old Qt then its just
#include <QMainWindow>also, make SURE no moc__ files are in the project folder. They are generated and should live in the build folder.
If it find old moc__ files, odd stuff will happen :)@mrjj Hi,
I had the newest version of Qt, but I don't know why I can't #include <QMainWindow>, because for some reasons ' cannot open source faile "QMainWindow".'
I should remove all files moc__ .. cpp also? I find them in project in folder x64/release/moc.
In pre-build event -> command line is command that creates moc.exe MainWindow.h -o moc_MainWindow.cpp
moc.exe GuiUpdatingThread.h -o moc_GuiUpdatingThread.cpp -
@mrjj Hi,
I had the newest version of Qt, but I don't know why I can't #include <QMainWindow>, because for some reasons ' cannot open source faile "QMainWindow".'
I should remove all files moc__ .. cpp also? I find them in project in folder x64/release/moc.
In pre-build event -> command line is command that creates moc.exe MainWindow.h -o moc_MainWindow.cpp
moc.exe GuiUpdatingThread.h -o moc_GuiUpdatingThread.cpp@Ewa-Miazga said in Problem with QMain Window:
x64/release/moc.
This seems ok as not a project folder directly.
But it also seems non standard which means that the -pro file might be special.Have you tried to go
File->New Project
then just Next, Next
Then you get a clean project with QMainWindow
Its just to see if that ones just works so we know if its this project somehow or something with the installation
-
Hi,
Seeing the age of the project, you likely are missing
QT += widgets
in your .pro file. -
@SGaist I added it, but it changed nothing.
-
@JoeCFD
in .pro file:
CONFIG += no_fixpath
QT += core uitools widgetsDEFINES -= UNICODE _UNICODE
-
@Ewa-Miazga said in Problem with QMain Window:
x64/release/moc.
This seems ok as not a project folder directly.
But it also seems non standard which means that the -pro file might be special.Have you tried to go
File->New Project
then just Next, Next
Then you get a clean project with QMainWindow
Its just to see if that ones just works so we know if its this project somehow or something with the installation
@mrjj
It works.
I decided to copy all the files to new console application qt project in visual studio and now I have plenty of unexternal symbols... -
The suggestion is to create a Qt Widgets application so you ensure that it's properly configured to build using the widgets module.
-
The suggestion is to create a Qt Widgets application so you ensure that it's properly configured to build using the widgets module.
@SGaist I checked it. It works.