If all you are adding is non-visible properties to your widget then you might as well just use the Promotion feature in Designer. Nothing special is required: drop a standard QLineEdit on your form and promote it to YourExtendedLineEdit.
If you have a widget that looks different then you might want to integrate it with Designer. There's a fully worked example of defining a new widget to Designer in Creating Custom Widgets for Qt Designer. You need to create a plugin and implement a couple of interfaces.
You'll need to get your widget designed properly first. As it is written above myAttrib is a private enum, so it will not be visible outside of an instance of myBase. You do not need multiple inheritance, but you will need macros to define the enum(s) and property (-ies) and expose the class
Something like:
#include <QLineEdit>
#include <QtDesigner/QDesignerExportWidget>
class QDESIGNER_WIDGET_EXPORT MyLineEdit
: public QLineEdit {
Q_OBJECT
Q_ENUMS(AttribEnum)
Q_PROPERTY(AttribEnum newAttrib READ newAttrib WRITE setNewAttrib)
public:
{
}
enum AttribEnum { valueA , valueB,valueC };
void setNewAttrib(const AttribEnum value) { m_newAttrib = value; };
AttribEnum newAttrib() const { return m_newAttrib; };
private:
AttribEnum m_newAttrib;
};
#include <QLineEdit>
#include <QtDesigner/QDesignerExportWidget>
class QDESIGNER_WIDGET_EXPORT MyLineEdit: public QLineEdit
{
Q_OBJECT
Q_ENUMS(AttribEnum)
Q_PROPERTY(AttribEnum newAttrib READ newAttrib WRITE setNewAttrib)
public:
MyLineEdit(QWidget *p = 0): QLineEdit(p), m_newAttrib(valueA)
{
}
enum AttribEnum { valueA , valueB,valueC };
void setNewAttrib(const AttribEnum value) { m_newAttrib = value; };
AttribEnum newAttrib() const { return m_newAttrib; };
private:
AttribEnum m_newAttrib;
};
To copy to clipboard, switch view to plain text mode
Bookmarks