[Qt-interest] Custom widget behaviour in designer preview

Friedemann Kleint Friedemann.Kleint at nokia.com
Fri May 29 08:42:55 CEST 2009


On Thursday 28 May 2009 04:35:33 pm ext Tom Cobb wrote:
Hi Tom,

>Is it possible for the
> QDesignerCustomWidgetInterface layer to know whether it is creating a
> widget for use in "Preview" or in "Design" mode?

There is no API for it, but a workaround is to check whether the parent widget
belongs to a form (editor) window:

#include <QtDesigner/QDesignerFormWindowInterface>

Widget *Plugin::createWidget(QWidget *parent)
{
   if (QDesignerFormWindowInterface *fw = 
QDesignerFormWindowInterface::findFormWindow(parent)) {
   	qDebug() << "Editor";
} else {
   	qDebug() << "Preview";
}
    return new CustomWidget(parent);
}

Regards,
Friedemann 
-- 
Friedemann Kleint
Nokia, Qt Software

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090529/3449b8f4/attachment.html 


More information about the Qt-interest-old mailing list