[ACCEPTED]-Promoting widgets in Qt Creator-promoting

Accepted answer
Score: 23

The header file that Designer asks you for 9 in the promotion dialog is YOUR own header file 8 that define the custom widget, not the generated 7 ui_*.h file.

Say you want to promote a plain QWidget to 6 MyCustomWidget, you must already have a MyCustomWidget.h that defines 5 your MyCustomWidget class included in your .pro file like 4 this:

HEADERS  += MyCustomWidget.h

And in the widget promotion dialog, just 3 type in MyCustomWidget.h. The purpose of it is so the generated 2 ui header file (wherever it is) can include 1 YOUR class definition.

Score: 3

I already figured this thing out - I was 11 promoting to my class, and giving header 10 name that was self-written, that was correct.

The 9 problem was that this (self written) file 8 was not directly in the project directory 7 but in src subdirectory (where all others sources 6 also are), I am not using subdirs template, but 5 simply adding them like

SOURCES += src/myWidget.cpp

The promoting option 4 doesn't require full path, but it needs 3 it as it appears in *.pro file - in this case 2 switching from myWidget.h to src/myWidget.h did the trick - and 1 it will work if I move or share it.

Score: 1

If the promoted widget form (.ui) and class files 5 (.cpp, .h) are in a Qt Creator project subdirectory 4 and j_kubik's solution does not help it 3 shows the error ("foo.h not found"), try to use just the header 2 file name for the promotion and provide 1 the path as INCLUDEPATH in the .pro file.

More Related questions