PDA

View Full Version : Created a custom widget in wizard, how to get it in designer



tescrin
25th June 2012, 22:52
So ugh. I'm trying to do an example custom widget using the custom widget wizard found in designer/creator.

(I.E. File, new project, other projects, custom widget..)

I did that, hit build, and I can't seem to figure out how to get that custom widget into the designer.
Presumably I'm missing a simple step. I'm crossing my fingers that this is enough information for you to know what step I happen to be missing.

Any help is appreciated, thanks!

EDIT: Maybe I need to include the plugin in whatever project wishes to add the custom plugin to it's form?

ChrisW67
26th June 2012, 03:04
I did that, hit build, and I can't seem to figure out how to get that custom widget into the designer.
What do you mean by "get that custom widget into the designer"? Do you mean:

Use the non-Qt widget in a Designer layout for another widget. You insert similar widget into the new design and use the Promotion feature to make it use your class instead. See Using Custom Widgets with Qt Designer
Make that custom widget appear in the widget tool box at the left of Designer. You need to create a plugin for Designer to enable this. See Creating Custom Widgets for Qt Designer

tescrin
26th June 2012, 15:37
First, I mean the plugin approach. I don't mean to be rude, but I *did* mention that I was trying to get a plugin to work in designer in the first post.

Second, NO. That tut was not helpful in figuring out WHY it won't show up in designer. I don't wish to write another 200 lines of code to have it *maybe* work when that hasn't worked two times before. I used the wizard to avoid that mess assuming that something that was completely automated to do *only* that task would work, built a wrapper around a QPushButton and I still see no "TestButton", if you will.

There seems to be some obvious step these tut's don't go out of their way to explain. I don't know what hoop you have to jump through to get the files in the right spot that it'll be happy about it. If it matters:

-I'm on Windows
-Latest release of Qt, using Qt Creator
-The code builds and works (for the button anyway) but does not get the object into designer. I would really like to figure out why it won't appear in my list

luisvt
9th August 2012, 23:21
There are two ways of doing that.

Adding a similar widget and Promoting this widget
1. Add the similar widget to your desing (for example a QTextEdit)
2. Copy and past the *.cpp and the *.h document to your project file
3. Add those documents to your project
4. On the Ui designer, Right Click over your widget
5. Press Promote to...
6. In the textbox Promote class name put the name of the class that you are going to add ("CodeEditor" for example, it is case sensitive).
7. Press Add Button
8. Press Promote Button

Watch this video


http://www.youtube.com/watch?v=-8o-6fLwEZ4