[Qt-interest] Trying to create custom Qt Designer plugin for real-time data

Keith Nicewarner Keith.Nicewarner at spacex.com
Wed Jan 20 21:19:13 CET 2010


Sorry for the delay.  Yes, that's exactly what I'm after.  I have a simple example that ALMOST works the way I wanted.  I used designer to create a "text channel" widget composed of a label and a read-only line edit box, both inside a horizontal layout.  Then my custom widget uses this form.  So now I'd like to create a dialog with an array of these widgets.  But here are some problems:

1. Label name always puts the colon in front (I reported this in a separate post).

2. When I drag and drop the new text channel widget into a form, designer acts like the geometry of the widget is detached from the actual drawing of the widget.  I can window-select and get a "ghost" rectangle for the widget and move and resize that but it doesn't affect the widgets that are drawn, and I can't click on the label or text box to select the widget.  I've never build a custom widget out of basic widgets so perhaps I'm not using the correct container?

3. When I create a new dialog and drag the text channel widget onto the form, the timer for polling data starts while I'm dragging but stops as soon as I release (place) the widget.  But when I save this dialog and then load the UI in designer, the timer works.

I've attached my simple code for reference.
Keith.

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Friedemann Kleint
Sent: Thursday, January 07, 2010 3:01 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Trying to create custom Qt Designer plugin for real-time data

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
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
A non-text attachment was scrubbed...
Name: text_channel.tgz
Type: application/x-compressed
Size: 2685 bytes
Desc: text_channel.tgz
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100120/3b434911/attachment.bin 


More information about the Qt-interest-old mailing list