[Qt-interest] Qt Designer Custom Widgets
Malyushytsky, Alex
alex at wai.com
Tue Nov 9 21:47:29 CET 2010
Josh Knox wrote:
>> No, its not wrong.
>> ….
Question was how to make promotion work.
No offence, but recommendation to use plugin was unrelated to question asked,
more of that such recommendation could be understood that there is no way to fix problem and promotion should NOT be used.
That is why it was wrong.
As for pluses and minuses in plugin and promotion system from my own experience:
Even though plugins are useful when you need to deliver your control to customer or need to load controls dynamically for any other purposes,
in all other circumstances it is overkill. The reason is efficiency: writing plugin takes time, more code to maintain, using plugins complicates installation,
plug-in system is more complicated than promotion, etc.
You may agree or disagree, but I don’t normally rent a truck when adjusting sit in the sedan is sufficient for me to fit.
Regards,
Alex
From: Josh Knox [mailto:jknox at irobot.com]
Sent: Monday, November 08, 2010 9:22 PM
To: Malyushytsky, Alex
Cc: Qt Interest
Subject: Re: [Qt-interest] Qt Designer Custom Widgets
Malyushytsky, Alex wrote:
You want to make a QtDesigner plugin.
Above is wrong.
No, its not wrong.
It works fine to create widgets that can be displayed in Designer. I've done it many times.
The docs cover it very well. Here's another example, from the Qt docs:
http://doc.qt.nokia.com/4.7/designer-customwidgetplugin.html
Easy.
Promoting is easy too and might be appropriate for this case where the derived class still looks like a QTextEdit for layout purposes.
Either way works. A plugin makes your class a 1st class citizen in designer. Promotion lets another widget stand in its place for layout purposes.
Josh
Plug-in is completely different from promotion feature.
All promotion does - it includes header your class is defined in, into
uic generated header and replace widget class name mentioned with operator new with your class name.
plugin makes much more.
As you mentioned you have to make sure that your CustomChatWindow.hpp is found.
What path to specify?
It is up to you, it just has to be correct path either relative or absolute, so that if placed in the
generated by uic file ( for your file it probably will be ui_CustomChatWindow.h ) it will be found by C++ compiler.
I would recommend avoiding absolute path.
If all the files you mentioned (cpp, hpp ) are included in your project already and Include Directories (INCLUDEPATH) contains path to the folder with CustomChatWindow.hpp you can just specify CustomChatWindow.hpp . This will add #include "CustomChatWindow.hpp" to the uic generated header.
Otherwise I would recommend specify relative path (make sure it is valid from the location of uic generated header ).
Regards,
Alex
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Josh Knox
Sent: Monday, November 08, 2010 10:41 AM
To: Alex Ivasyuv
Cc: Qt Interest
Subject: Re: [Qt-interest] Qt Designer Custom Widgets
Alex Ivasyuv wrote:
Hi,
I need to implement customTextEditWidget of QTextEdit.
I created custom class, which implements QTextEdit, called CustomChatWindow (cpp & hpp files).
Now I would like to use this custom class in QT Designer.
I found in docs, that I could use "Promote" feature, but when I do this, I get on app start the following error:
"QFormBuilder was unable to create a custom widget of the class 'CustomChatWindow'; defaulting to base class 'QTextEdit'."
I think issue in name of header file that you have to clarify in popup dialog
http://doc.qt.nokia.com/4.7/images/designer-promoting-widgets.png ("Header file").
I have CustomChatWindow.hpp & CustomChatWindow.cpp. And they lies in some subfolders.
What should I pointed there? Relative or absolute path to header file? Or maybe only here header file name? If so, related of what...
I found here a video http://www.youtube.com/watch?v=Yt-YCxgEnyw, but it's a custom widget created by Designer.
Thanks,
You want to make a QtDesigner plugin.
See this:
http://doc.qt.nokia.com/4.7/designer-creating-custom-widgets.html
and this example:
http://doc.qt.nokia.com/4.7/designer-customwidgetplugin.html
Josh
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list