In qt 5.2.1 I've created some custom widgets, like a button. Traditionally there's two ways of doing this. You can either promote an existing widget. And change/add functionality. Or create a custom widget from scratch. I've used the latter.
However, in some cases I would like to use my custom widget, but change some of it's functionality by promoting. The usual way to do this would be to add a widget, and promote it. However, when creating a new kind of promoted widget, a base class has to be picked. And in the dialog where this can be done, only the default widgets are listed.
Is it possible to add a custom widget to this list?
Regards,
Lauris
Edit:
I've played around with it a lot. And now all of a sudden a custom widget is been added to the list of base classes. Yet I still don't know how I've added it. And why this is the only custom widget showing on the list.
Adding the Custom Widget to Qt Designer. Click Tools|Custom|Edit Custom Widgets to invoke the Edit Custom Widgets dialog. Click New Widget so that we are ready to add our new widget. Change the Class name from 'MyCustomWidget' to 'Vcr'.
Qt Widgets provide means for customization via style sheets, but Qt Quick is a better performing choice for user interfaces that do not aim to look native. Qt Widgets do not scale well for animations. Qt Quick offers a convenient and natural way to implement animations in a declarative manner.
Widgets are the primary elements for creating user interfaces in Qt. Widgets can display data and status information, receive user input, and provide a container for other widgets that should be grouped together. A widget that is not embedded in a parent widget is called a window.
QStackedWidget can be used to create a user interface similar to the one provided by QTabWidget. It is a convenience layout widget built on top of the QStackedLayout class. Like QStackedLayout, QStackedWidget can be constructed and populated with a number of child widgets ("pages"):
This seems to be a bug in Qt Creator. A workaround, oddly enough is to add widgets twice to the list of widgets a widget library exports:
IOSwidgets::IOSwidgets(QObject *parent)
: QObject(parent)
{
m_widgets.append(new aircraftAttitudePlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new alfabeticKeypadPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new arrowedFramePlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new buttonWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new dataButtonPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new frameWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new headingDialPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new imageWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new labelWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new linkedButtonWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new linkedLabelWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new linkedSliderWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new NavButtonPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new numericKeypadPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new repositionWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new runwayInformationPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new slewWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new sliderWidgetPlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new WeightBalancePlugin(this));
m_widgets.append(m_widgets.last());
m_widgets.append(new WindshearMicroburstLateralPlugin(this));
m_widgets.append(m_widgets.last());
}
Hope this saves the next person who runs into this problem, the painstaking effort and the huge amount of time it took me to find this out:).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With