Hello,

I wrote my own ButtonPlugin for the QtDesigner. In addition I implemented for this ButtonPlugin an own ButtonPropertySheetExtension.

I used the template from QtCreator for creating QtDesigner-Plugins and only changed the following function in ButtonPlugin.cpp:

Qt Code:
  1. void ButtonPlugin::initialize(QDesignerFormEditorInterface * core)
  2. {
  3. if (m_initialized)
  4. return;
  5.  
  6. QExtensionManager *manager = core->extensionManager();
  7. Q_ASSERT(manager != 0);
  8.  
  9. manager->registerExtensions(new ButtonPropertyFactory(manager), Q_TYPEID(QDesignerPropertySheetExtension));
  10.  
  11. m_initialized = true;
  12. }
To copy to clipboard, switch view to plain text mode 

In addition I created ButtonPropertySheetExtension.h:
Qt Code:
  1. #include <QObject>
  2. #include <QMap>
  3. #include <QString>
  4. #include <QDesignerPropertySheetExtension>
  5. #include <QExtensionFactory>
  6.  
  7. #include "button.h"
  8.  
  9. /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  10. ButtonPropertyFactory
  11. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
  12. class ButtonPropertyFactory : public QExtensionFactory
  13. {
  14. Q_OBJECT
  15.  
  16. public:
  17. ButtonPropertyFactory(QExtensionManager *parent = 0);
  18.  
  19. protected:
  20. QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const;
  21. };
  22.  
  23. /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  24. ButtonPropertySheetExtension
  25. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
  26. class ButtonPropertySheetExtension : public QObject, QDesignerPropertySheetExtension
  27. {
  28. Q_OBJECT
  29.  
  30. public:
  31. ButtonPropertySheetExtension(Button* p, QObject *parent);
  32.  
  33.  
  34. int count (void) const;
  35. bool hasReset ( int index ) const;
  36. int indexOf ( const QString & name ) const;
  37. bool isAttribute ( int index ) const;
  38. bool isChanged ( int index ) const;
  39. bool isVisible ( int index ) const;
  40. QVariant property ( int index ) const;
  41. QString propertyGroup ( int index ) const;
  42. QString propertyName ( int index ) const;
  43. bool reset ( int index );
  44. void setAttribute ( int index, bool attribute );
  45. void setChanged ( int index, bool changed );
  46. void setProperty ( int index, const QVariant & value );
  47. void setPropertyGroup ( int index, const QString & group );
  48. void setVisible ( int index, bool visible );
  49.  
  50. protected:
  51.  
  52. Button* _powner;
  53. const QMetaObject* _p_metaobject;
  54.  
  55. QMap<int, QString> _PropertyGroups;
  56. };
To copy to clipboard, switch view to plain text mode 

And I created ButtonPropertySheetExtension.cpp:
Qt Code:
  1. /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  2. ButtonPropertyFactory
  3. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
  4. ButtonPropertyFactory::ButtonPropertyFactory(QExtensionManager *parent)
  5. {
  6. }
  7.  
  8.  
  9. QObject *ButtonPropertyFactory::createExtension(QObject *object,
  10. const QString &iid,
  11. QObject *parent) const
  12. {
  13. if (iid != Q_TYPEID(QDesignerPropertySheetExtension))
  14. return 0;
  15.  
  16. if (Button* pbutton = qobject_cast<Button*>(object))
  17. return new ButtonPropertySheetExtension(pbutton, parent);
  18.  
  19. return 0;
  20. }
  21. /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  22. ButtonPropertySheetExtension
  23. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
  24.  
  25.  
  26. ButtonPropertySheetExtension::ButtonPropertySheetExtension(Button* p, QObject *parent) :
  27. QObject(parent),
  28. _powner(p),
  29. _p_metaobject(_powner->metaObject()),
  30. _PropertyGroups()
  31. {
  32. const int i_object_index = indexOf("objectName");
  33. setPropertyGroup(i_object_index, "QObject");
  34.  
  35. const int i_widget_index = indexOf("modal");
  36. setPropertyGroup(i_widget_index, "QWidget");
  37.  
  38. const int i_abstractbutton_index = indexOf("text");
  39. setPropertyGroup(i_abstractbutton_index, "QAbstractButton");
  40.  
  41. const int i_pushbutton_index = indexOf("autoDefault");
  42. setPropertyGroup(i_pushbutton_index, "QPushButton");
  43. }
  44.  
  45. int ButtonPropertySheetExtension::count () const
  46. {
  47. return _p_metaobject->propertyCount();
  48. }
  49.  
  50. bool ButtonPropertySheetExtension::hasReset ( int index ) const
  51. {
  52. return _p_metaobject->property(index).isResettable();
  53. }
  54.  
  55. int ButtonPropertySheetExtension::indexOf ( const QString & name ) const
  56. {
  57. return _p_metaobject->indexOfProperty( name.toLatin1().constData() );
  58. }
  59.  
  60. bool ButtonPropertySheetExtension::isAttribute ( int index ) const
  61. {
  62. Q_UNUSED(index)
  63. return false;
  64. }
  65.  
  66. bool ButtonPropertySheetExtension::isChanged ( int index ) const
  67. {
  68. Q_UNUSED(index)
  69. return false;
  70. }
  71.  
  72. bool ButtonPropertySheetExtension::isVisible ( int index ) const
  73. {
  74. Q_UNUSED(index)
  75. return true;
  76. }
  77.  
  78. QVariant ButtonPropertySheetExtension::property ( int index ) const
  79. {
  80. return _p_metaobject->property(index).read(_powner);
  81. }
  82.  
  83. QString ButtonPropertySheetExtension::propertyGroup ( int index ) const
  84. {
  85. QMap<int, QString>::const_iterator it = _PropertyGroups.begin();
  86. if (index > 0){
  87. while (it.key() <= index){
  88. it++;
  89. }
  90. it--;
  91. }
  92. return it.value();
  93. }
  94.  
  95. QString ButtonPropertySheetExtension::propertyName ( int index ) const
  96. {
  97. return QString(_p_metaobject->property(index).name());
  98. }
  99.  
  100. bool ButtonPropertySheetExtension::reset ( int index )
  101. {
  102. return _p_metaobject->property(index).reset(_powner);
  103. }
  104.  
  105. void ButtonPropertySheetExtension::setAttribute ( int index, bool attribute )
  106. {
  107. Q_UNUSED(index)
  108. Q_UNUSED(attribute)
  109. }
  110.  
  111. void ButtonPropertySheetExtension::setChanged ( int index, bool changed )
  112. {
  113. Q_UNUSED(index)
  114. Q_UNUSED(changed)
  115. }
  116.  
  117. void ButtonPropertySheetExtension::setProperty ( int index, const QVariant & value )
  118. {
  119. QMetaProperty metaproperty = _p_metaobject->property(index);
  120. metaproperty.write(_powner, value);
  121. }
  122.  
  123. void ButtonPropertySheetExtension::setPropertyGroup ( int index, const QString & group )
  124. {
  125. _PropertyGroups.insert(index, group);
  126. }
  127.  
  128. void ButtonPropertySheetExtension::setVisible ( int index, bool visible )
  129. {
  130. Q_UNUSED(index)
  131. Q_UNUSED(visible)
  132. }
To copy to clipboard, switch view to plain text mode 

So my question, why is the attribute "icon" of QAbstractButton not shown in QtDesigner?

The same behaviour occurs by implementing - for example LabelPlugin (QLabel). Here the "pixmap" Property will be not shown.

I would be very happy aboput any good advice.
Thanks