[Qt-interest] Trying to create custom Qt Designer plugin for real-time data
Friedemann Kleint
Friedemann.Kleint at nokia.com
Thu Jan 7 12:01:12 CET 2010
Hi,
hoping I understand the problem correctly, I would suggest:
1) Declare the 'channel' property in the custom widget header:
Q_PROPERTY(QString channel READ channel WRITE setChannel DESIGNABLE true)
(see http://doc.trolltech.com/4.6/qobject.html#Q_PROPERTY ) and implement the
getters/setters. The property will then appear in the property editor of Qt
Designer, enabling the user to enter a channel name.
Alternatively, if you want to present a combo box listing the available
channels in a dialog box, you could implement a QDesignerTaskMenuExtension
instance for your custom widget (see
http://doc.trolltech.com/4.6/qdesignertaskmenuextension.html), It would then
set the channel chosen using QDesignerFormWindowCursorInterface::setProperty
(see http://doc.trolltech.com/4.6/qdesignerformwindowcursorinterface.html).
2) I assume it is desirable that the data retrieval is not triggered by the
widgets on the form editor while editing. To achieve that, you could for
example add a hidden property
Q_PROPERTY(bool dataRetrievalActive READ isDataRetrievalActive WRITE
setDataRetrievalActive DESIGNABLE false)
defaulting to true. You would then set it to false if the widget is located on
a form in the implementation of
QDesignerCustomWidgetInterface::createWidget(). To find out if the widget is on
a form, QDesignerFormWindowInterface::findFormWindow() can be used on the
parent parameter:
MyCustomWidgetInterface::createWidget(QWidget *parent)
{
MyWidget *mw = new MyWidget(parent);
if (QDesignerFormWindowInterface::findFormWindow(parent))
mw->setDataRetrievalActive(false);
...
Data retrieval would then start as soon as the user does a preview of the
form.
I hope this helps,
Regards,
Friedemann
--
Friedemann Kleint
Nokia, Qt Development Frameworks
More information about the Qt-interest-old
mailing list