Results 1 to 14 of 14

Thread: EXtend functionality of QListWidget by making a plugin and use it in designer?

  1. #1
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default EXtend functionality of QListWidget by making a plugin and use it in designer?

    Hi All
    i have made a plugin for designer and it is showing in designer and i can use it only problem is that none of the propertys typical for QListwidget is visible in designer even though i did let my class subclass QListwidget. It is only the baseclass QWidget propertys that is accesible which means that i cant access a lot of the propertys that is present in QListWidget.

    Now! is this not possible to achive? it seems to me it must be possible since they can make QT3plugins visible and usable in designer with all the propertys visible.

    I will post my code now and see if someone can tell me if it is possible and if maybe i have done something wrong. now the only thing i have donee is to add a variable of the type QDate to the QListView but this was only so that i could figure out how the plugin was made. I am going to add more functions if i get it to show up as an extended QListWidget in Designer

    dateViewList.h defining the class dateViewList and letting it subclass QListWidget

    Qt Code:
    1. #ifndef DATEVIEWLIST_H
    2. #define DATEVIEWLIST_H
    3. #include <QListView>
    4. #include <QDate>
    5. #include <QObject>
    6. #include <QWidget>
    7. #include <QtDesigner/QDesignerExportWidget>
    8. #include <QListWidget>
    9. #include <QObject>
    10.  
    11.  
    12. class QDESIGNER_WIDGET_EXPORT dateViewList : private QListWidget {
    13.  
    14. Q_OBJECT
    15.  
    16.  
    17. public :
    18. dateViewList(QWidget *parent );
    19.  
    20. public:
    21. void setDate(QDate otherDate);
    22.  
    23.  
    24. private:
    25. QDate displayDate;
    26.  
    27.  
    28. };
    29. #endif
    To copy to clipboard, switch view to plain text mode 


    Implementing Class dateListView.cpp
    Qt Code:
    1. #include "dateViewList.h"
    2. #include <QDate>
    3. #include <qdatetime.h>
    4. #include <qwidget.h>
    5. #include<QtGui>
    6.  
    7.  
    8.  
    9. dateViewList:: dateViewList(QWidget *parent ){
    10.  
    11.  
    12. }
    13.  
    14. void dateViewList :: setDate(QDate otherDate){
    15.  
    16. this->displayDate = otherDate;
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 

    Defining customwidgetplugin.h

    Qt Code:
    1. #ifndef CUSTOMWIDGETPLUGIN_H
    2. #define CUSTOMWIDGETPLUGIN_H
    3. #include <QDesignerCustomWidgetInterface>
    4. #include <QtPlugin>
    5. #include <QListWidget>
    6.  
    7. class extendedListWidgetPlugin : public QObject , public QDesignerCustomWidgetInterface
    8. {
    9.  
    10. Q_OBJECT
    11.  
    12. public: extendedListWidgetPlugin(QWidget *parent = 0);
    13.  
    14. bool isContainer() const;
    15. bool isInitialized() const;
    16. QIcon icon() const;
    17. QString domXml() const;
    18. QString group() const;
    19. QString includeFile() const;
    20. QString name() const;
    21. QString toolTip() const;
    22. QString whatsThis() const;
    23. QListWidget *createWidget(QWidget *parent);
    24. void initialize(QDesignerFormEditorInterface *core);
    25.  
    26. private:
    27. bool initialized;
    28. };
    29.  
    30. #endif
    To copy to clipboard, switch view to plain text mode 

    implementing customwidgetplugin.cpp

    Qt Code:
    1. #include "dateViewList.h"
    2. #include <string>
    3. #include <qstring.h>
    4. #include <qobject.h>
    5. #include <qwidget.h>
    6. #include "customwidgetplugin.h"
    7. #include <QtPlugin>
    8. #include <qstringlist.h>
    9. #include <QListWidget>
    10.  
    11.  
    12.  
    13. extendedListWidgetPlugin :: extendedListWidgetPlugin(QWidget *parent){
    14.  
    15. initialized = false;
    16.  
    17. }
    18.  
    19. void extendedListWidgetPlugin :: initialize(QDesignerFormEditorInterface * /* core */)
    20.  
    21. {
    22. if (initialized)
    23. return;
    24.  
    25. initialized = true;
    26. }
    27.  
    28. QListWidget *extendedListWidgetPlugin :: createWidget(QWidget *parent)
    29. {
    30. return new dateViewList(parent);
    31. }
    32.  
    33.  
    34. bool extendedListWidgetPlugin :: isInitialized() const
    35. {
    36. return initialized;
    37. }
    38.  
    39. QString extendedListWidgetPlugin::name() const
    40. {
    41. return "bikeDateList";
    42. }
    43.  
    44. QString extendedListWidgetPlugin::group() const
    45. {
    46. return "Display Widgets [PLUGINS]";
    47. }
    48.  
    49. QIcon extendedListWidgetPlugin :: icon() const
    50. {
    51. return QIcon("./hart.jpg");
    52. }
    53.  
    54. QString extendedListWidgetPlugin :: toolTip() const
    55. {
    56. return "DateViewList";
    57. }
    58.  
    59. QString extendedListWidgetPlugin :: whatsThis() const
    60. {
    61. return "Special widget for making Calender";
    62. }
    63.  
    64. bool extendedListWidgetPlugin::isContainer() const
    65. {
    66. return true;
    67. }
    68.  
    69. QString extendedListWidgetPlugin :: domXml() const
    70. {
    71. return "<widget class=\"dateViewList\" name=\"bikeDateList\">\n"
    72. " <property name=\"geometry\">\n"
    73. " <rect>\n"
    74. " <x>0</x>\n"
    75. " <y>0</y>\n"
    76. " <width>100</width>\n"
    77. " <height>100</height>\n"
    78. " </rect>\n"
    79. " </property>\n"
    80. " <property name=\"toolTip\" >\n"
    81. " <string>date Holder</string>\n"
    82. " </property>\n"
    83. " <property name=\"whatsThis\" >\n"
    84. " <string>dateViewList holds property of the date "
    85. "and functions to manipulate the list</string>\n"
    86. " </property>\n"
    87. "</widget>\n";
    88. }
    89.  
    90. QString extendedListWidgetPlugin ::includeFile() const
    91. {
    92. return "dateViewList.h";
    93. }
    94.  
    95. Q_EXPORT_PLUGIN2(customwidgetplugin , extendedListWidgetPlugin)
    To copy to clipboard, switch view to plain text mode 



    I understand i may not be able to set the extra attributes and variables i add to my class in designer but all the standard things like frame and stuff that is present in a ordinary QListWidget should at least be accessible in my plugin.

    Anyone familliar with plugins?
    ALL thoughts are Welcome exept for ppl loking for telemarket agencies!!

    Cheers

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    Just change this line:

    Qt Code:
    1. class QDESIGNER_WIDGET_EXPORT dateViewList : private QListWidget {
    To copy to clipboard, switch view to plain text mode 

    to:

    Qt Code:
    1. class QDESIGNER_WIDGET_EXPORT dateViewList : public QListWidget {
    To copy to clipboard, switch view to plain text mode 

    That aught to do it.

  3. #3
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    unfortunatly that did'nt do it. the properties for QFrame and QabstractScrollarea and more are still not visible in designer. I will attach two screenshots to better explain the situation. in the customwidget screenshot i have added a custom widget and marked it for editing so that u can see the properties available for editing in the property editor.In the qtwidget screenshot i have done the same but with a ordinary QListWidget.

    confused.......
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    Qt Code:
    1. dateViewList:: dateViewList(QWidget *parent ){}
    To copy to clipboard, switch view to plain text mode 
    You're not calling the base class (QListWidget) constructor.

    Should be:

    Qt Code:
    1. dateViewList:: dateViewList(QWidget *parent ) : QListWidget(parent){}
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    I changed the dateListView.cpp to the following...BUT i am still not able to edit all the propertys of a QListWidget in Designer.



    Qt Code:
    1. dateViewList :: dateViewList( QWidget* parent )
    2. : QListWidget(parent)
    3. {
    4. }
    To copy to clipboard, switch view to plain text mode 

    So i am wondering is this part right in the customwidgetplugin.cpp
    Qt Code:
    1. QListWidget *createWidget(QWidget*parent){returnnewdateListWidget()
    2. };
    To copy to clipboard, switch view to plain text mode 
    Or should it be
    Qt Code:
    1. QWidget* createWidget(QWidget *parent){return new dateListWidget()}
    To copy to clipboard, switch view to plain text mode 
    Or even
    Qt Code:
    1. dateListView* createWidget(QWidget *parent){return new dateListWidget() }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    or is this all to do with the propertyEditor?
    QDesignerFormEditorInterface :: propertyEditor ()

    Is this what i somehow have to incorporate in my plugin?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    Quote Originally Posted by Sisyfos View Post
    So i am wondering is this part right in the customwidgetplugin.cpp
    It should be
    Qt Code:
    1. QWidget* createWidget(QWidget *parent){return new dateListWidget(parent);}
    To copy to clipboard, switch view to plain text mode 

    I suggest you take a look at an example of making a Qt Designer plugin that comes with Qt docs.

  8. #8
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    Oh! i have read them time and time again!
    The plugin is showing in designer so in that way i have done exactly as far as the example in the documentation takes me. But i have read numerous post, (on this FORUM and others. Here is onehttp://www.qtforum.org/thread.php?th...ght=Q+PROPERTY), that is asking exactly what i am asking. The problem is that none of the posts have any replies in them.
    So i am starting to think it is not possible.
    I think that it is only possible to edit the properties of the base class QWidget even though the documentation vaguely suggests that it is supposed to be possible to make the properties editable in designer by declaring Q_PROPERTY() in the class declaration.
    SO if someone can prove me wrong i will jump with joy.
    Last edited by Sisyfos; 13th December 2006 at 22:40.

  9. #9
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?


  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    Quote Originally Posted by Sisyfos View Post
    Here is onehttp://www.qtforum.org/thread.php?th...ght=Q+PROPERTY), that is asking exactly what i am asking.
    It's not exactly what you are asking. The poster there can't add any properties, and you can't see the ones which are already there.

    So i am starting to think it is not possible.
    I assure you it's possible.

    I think that it is only possible to edit the properties of the base class QWidget even though the documentation vaguely suggests that it is supposed to be possible to make the properties editable in designer by declaring Q_PROPERTY() in the class declaration.
    SO if someone can prove me wrong i will jump with joy.
    Of course it's possible to add new properties and to see existing ones.

    Here you go, you may base your widget on the code attached.
    Attached Files Attached Files
    Last edited by wysota; 13th December 2006 at 23:18. Reason: Added the example code

  11. The following user says thank you to wysota for this useful post:

    Sisyfos (14th December 2006)

  12. #11
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    I have not yet had the time to analyse exactly what i did wrong. I will have to look at that in the morning when my brain has regained capacity enough to grasp what u have done. BUT i just wanted to thank u so VERY much for taking the time to look at my sad example and point me in the right direction. I have tried for two days now to figure out what u did in a couple of minutes. So it is really a load of my shoulders. Again THX!

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    That's not my first Qt Designer plugin, I also learned on my mistakes while making my first plugins.

  14. #13
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    Quote Originally Posted by wysota View Post
    That's not my first Qt Designer plugin, I also learned on my mistakes while making my first plugins.
    I sort of figured it was not your first plugin
    There were a number of problems with my code but most of all i had not understod the part where u call the base class constructor which seems to have caused some problems. But on thing i am wondering about is it really necessary to include the QCoreApplication. Cause it seems as if it was needed in my program but it is not clear from the documentation that it is needed in cases like this.
    BUT then again i dont find the documentation to be very good it leaves a lot of guessing to be done.

    Anyway i changed my code according to your example that u attached and now everything works just fine and i am happy as a clam.
    I recommend all ppl that are having any problems with their plugins to take a look at the code that Wysota has attached. It is a good base to stand on.

  15. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: EXtend functionality of QListWidget by making a plugin and use it in designer?

    Quote Originally Posted by Sisyfos View Post
    But on thing i am wondering about is it really necessary to include the QCoreApplication. Cause it seems as if it was needed in my program but it is not clear from the documentation that it is needed in cases like this.
    QCoreApplication is responsible for initialising plugins.

    BUT then again i dont find the documentation to be very good it leaves a lot of guessing to be done.
    That's your opinion According to me it just doesn't try to be smarter than the reader as some docs do.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.