Results 1 to 4 of 4

Thread: How to create a Qt Designer plugin derived from QStackedWidget?

  1. #1
    Join Date
    Aug 2012
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to create a Qt Designer plugin derived from QStackedWidget?

    Hi,

    I derived QStackedWidget and added some minor, but important functionality. Now I need a seperate element (plugin) for Qt Designer for our designers to choose wether they want to use the unmodified QStackedWidget or our custom version. Promoting the QStackedWidget is out of question, a separate design element is explicitly demanded.

    After reading the FAQ, examples, Qt doc, googling it and searching through the Qt Designer source code I cannot find any way to easily derive from the QStackedWidget element in Qt Designer. Is there any way to easily modify the QStackedWidget element in Qt Designer and add it as a seperate plugin?

    (I read http://doc.qt.nokia.com/4.7-snapshot...getplugin.html and similar documentation, but if I don't find any QStackedWidgetPlugin class or similar to derive from it's a lot of work to completely reimplement the QStackedWidget for Qt Designer)

    Cheers

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to create a Qt Designer plugin derived from QStackedWidget?

    Huh??
    Did you REALLY read the exmpale in the link you posted and the relevant class documentation here:
    http://doc.qt.nokia.com/4.7-snapshot/plugins-howto.html
    ?

    If you want a custom widget to be available as a designer plugin, you basically just wrap it in a QDesignerCustomWidgetInterface implementation, as in the docs.
    There are no widget specific plugin calsses such as QStackedWidgetPlugin - this is a class YOU have to implement with the mentioned interface.

    but if I don't find any QStackedWidgetPlugin class or similar to derive from it's a lot of work to completely reimplement the QStackedWidget for Qt Designer
    Define "a lot of work".
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2012
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to create a Qt Designer plugin derived from QStackedWidget?

    Yes, I read that documentation.

    I understand that I can write my very own plugin by doing something like:
    Qt Code:
    1. class MyPlugin : public QObject, public QDesignerCustomWidgetInterface
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MyPlugin(QObject *parent = 0);
    7. [dozen of functions to implement]
    8.  
    9. private:
    10. bool initialized;
    11. };
    To copy to clipboard, switch view to plain text mode 

    But I don't want to build a whole new plugin. That would mean that I'd have to implement all the functions of that interface plus the special handling of the 'initialized' state for a class derived from QStackedWidget i.e. menus for handling the pages etc. That's what I think of as a lot of work, just by comparing how much code is in http://etudiant.istic.univ-rennes1.f...stackedbox.cpp

    What I would like to see is something like:
    Qt Code:
    1. class MyPlugin : public QObject, public [B]QStackedWidgetPlugin[/B]
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MyPlugin(QObject *parent = 0);
    7. [only few functions to implement]
    8.  
    9. private:
    10. bool initialized;
    11. };
    To copy to clipboard, switch view to plain text mode 

    Do you see my problem now?
    Am I not properly understanding how this works?

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to create a Qt Designer plugin derived from QStackedWidget?

    [dozen of functions to implement]
    I count exactly 12 virtual methods of QDesignerCustomWidgetInterfacethe must be implemented, most of them completely trivial (like returning QStrings with the name, tool tip, header file name, etc.). The example you linked to is Qt's code for other interfaces for QStackedWidget. If all you are doing is extending QStackedWidget to have a few additional properties, then you can probably just derive from those interfaces and modify only what is required to implement these new features, if anything. Otherwise, your code will simply call the base class code.

    Am I not properly understanding how this works?
    Doesn't look like you are from this end of the Internet.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Qwt plugin on Qt Designer 4.7.3
    By DarkMan20050 in forum Qt Tools
    Replies: 4
    Last Post: 4th July 2012, 14:27
  2. How to create a plugin
    By MTK358 in forum Qt Programming
    Replies: 24
    Last Post: 27th August 2010, 17:22
  3. Create new signal for derived widget
    By GadiK in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2009, 12:27
  4. Designer plugin segfaults designer :(
    By tmarki in forum Qt Tools
    Replies: 4
    Last Post: 26th September 2007, 12:22
  5. Replies: 1
    Last Post: 22nd January 2007, 13:13

Tags for this Thread

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.