PDA

View Full Version : using pre-created widgets in Qt Creator/Qt Designer



flashburn
24th September 2016, 01:29
I need to build a GUI that has flight instruments in it. I found these ones (https://sourceforge.net/projects/qfi/) , however I can't figure out how to use them with Qt Creator/Qt Designer. One way that was recommended online is to promote a widget to a new widget. So I dropped a widget onto a form and tried to promote it to WidgetNAV. However during compilation I got an error saying that WidgetNAV.h was not found. Clearly I'm missing something here, would anyone be able to help me out?

d_stranz
24th September 2016, 17:30
Qt Designer and Qt Creator are different programs; Qt Designer is an editor for .UI files, while Qt Creator is both an editor for .h and .cpp files as well as an environment for controlling compiling, linking, and debugging your programs.

If your WidgetNAV.h files is not in the same directory as the rest of your source code, then you need to modify your project's .pro file to add the path to the directory that contains that file. Likewise, you have to add the path and filename of the library containing WidgetNAV to the .pro file. After that, you need to run qmake again (if Qt Creator does not do it automatically for you) so Qt Creator can find these files when it compiles or links.

If your library does not come with a Qt Designer plugin, then the only way you can use the widgets is through the promotion mechanism. Be careful that you are spelling the name of the widget -exactly- the same as it is named in the .h file, otherwise you will still get compile errors.