UI Builder
-
Hi
I am trying to access a form that I made in the Qt Designer.I get the following error after putting a module link in my .pro file.
I get the following error : :-1: error: Project ERROR: Unknown module(s) in QT: : QT += uibuilderCan anyone help ?
-
I'm not aware of such a module - why do you think you need it?
See https://doc.qt.io/qt-6/designer-using-a-ui-file.html on how to use an ui file in your application. -
I removed that line.
I then get the following linker errors :
main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl QUiLoader::QUiLoader(class QObject *)" (??0QUiLoader@@QEAA@PEAVQObject@@@Z) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __cdecl QUiLoader::~QUiLoader(void)" (??1QUiLoader@@UEAA@XZ) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "public: class QWidget * __cdecl QUiLoader::load(class QIODevice *,class QWidget *)" (?load@QUiLoader@@QEAAPEAVQWidget@@PEAVQIODevice@@PEAV2@@Z) referenced in function main -
Ah, you are using QUILoader (for unknown reasons). Then you should use
QT += uitools
as written in the documentation: https://doc.qt.io/qt-6/quiloader.html -
Ok I tried your suggestion but then the program doesn't seem to run ? -
Please do not post screenshots.
Since you did not post your code I don't know what you're doing wrong. There are a lot of Qt examples out there on how to use ui files: https://doc.qt.io/qt-6/examples-widgets.html -
Ok, here is the code for the main function :
int main(int argc, char *argv[]) {
QApplication app(argc, argv);QFile file("MainMenu.ui"); file.open(QFile::ReadOnly); QUiLoader loader; QWidget *widget = loader.load(&file); // Load the UI file dynamically file.close(); if (!widget) return -1; widget->show(); ChessBoard board; board.show(); return app.exec();
}
-
Hi,
You are using a relative path. You ui file is not located in the build folder thus it cannot be loaded.
You should add proper error checking to your QFile code. It would have caught the issue.
-
I still don't know what you're trying to achieve by loading a ui file directly and then simply showing it. You should also check if the file could be opened successfully if you want to stay with the loading of the ui file.
Use a debugger to see where exactly it is crashing. i would guess somewhere inside your ChessBoard class. -
Thanks for the help. The problem was the relative path. It is working now.
-
Ok the next issue has arisen.
When I try and create a signal on the "New Standard Game", it says no documents matching ui_MainMenu.h could be found ? -
Ok the next issue has arisen.
When I try and create a signal on the "New Standard Game", it says no documents matching ui_MainMenu.h could be found ?@YorkCleave said in UI Builder:
When I try and create a signal on the "New Standard Game", it says no documents matching ui_MainMenu.h could be found ?
We don't know what "New Standard Game" means in your case and we can't see what you are doing.
ui_MainMenu.h
is the translated UI Header, which should have nothing to do with Signals & Slots, unless you are connecting to the UI of another class, which is not a good way and might lead to issue sooner or later. -
Ok the next issue has arisen.
When I try and create a signal on the "New Standard Game", it says no documents matching ui_MainMenu.h could be found ?@YorkCleave Is there a reason why you're using QUiLoader?
-
Ok. is it ok if I post a screenshot of MainMenu here ?