Results 1 to 8 of 8

Thread: QT4 custom designer plugin properties ignored

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4 custom designer plugin properties ignored

    I was able to reproduce your problem and it seems that Designer gets confused when you have two plugins for widgets with the same class name.

    Make sure:
    • that the name of a class in XML snippet returned by domXml() and the string returned by name() are the same as the widget's class name,
    • that there are no other plugins which name() method returns the same string (you might already have one plugin for AnalogClock widget installed),
    • and finally that you compile your plugin in release mode.


    Rename AnalogClock to something like AnalogClockX, update your plugin's code:
    Qt Code:
    1. ...
    2.  
    3. QString AnalogClockPlugin::name() const
    4. {
    5. return "AnalogClockX";
    6. }
    7.  
    8. ...
    9.  
    10. QString AnalogClockPlugin::domXml() const
    11. {
    12. return "<widget class=\"AnalogClockX\" name=\"analogClock\">\n"
    13. ...
    14. "</widget>\n";
    15. }
    16.  
    17. ...
    18.  
    19. QString AnalogClockPlugin::includeFile() const
    20. {
    21. return "mycustom.h";
    22. }
    To copy to clipboard, switch view to plain text mode 
    and run:
    Qt Code:
    1. make -f Makefile.Release
    To copy to clipboard, switch view to plain text mode 
    After this you should get a working plugin:
    Qt Code:
    1. <customwidget>
    2. <class>AnalogClockX</class>
    3. <extends>QWidget</extends>
    4. <header>mycustom.h</header>
    5. <container>0</container>
    6. <pixmap></pixmap>
    7. </customwidget>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4 custom designer plugin properties ignored

    awesome
    ok now at least i have a working example
    i gotta figure out if this is what could be causing my issue with my custom widgets in my collection

    they are having issues too but they have unique names


    im going to try and alter this example code to use a collection and see if all of the widgets in the collection work. or not

    now i have a working plugin to experiment off of though!

    thanks jacek!

  3. #3
    Join Date
    Oct 2014
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: QT4 custom designer plugin properties ignored

    Quote Originally Posted by jacek View Post
    I was able to reproduce your problem and it seems that Designer gets confused when you have two plugins for widgets with the same class name.

    Make sure:
    • that the name of a class in XML snippet returned by domXml() and the string returned by name() are the same as the widget's class name,
    • that there are no other plugins which name() method returns the same string (you might already have one plugin for AnalogClock widget installed),
    • and finally that you compile your plugin in release mode.


    Rename AnalogClock to something like AnalogClockX, update your plugin's code:
    Qt Code:
    1. ...
    2.  
    3. QString AnalogClockPlugin::name() const return "AnalogClockX";
    4. }
    5.  
    6. ...
    7.  
    8. QString AnalogClockPlugin::domXml() const
    9. {
    10. return "<widget class=\"AnalogClockX\" name=\"analogClock\">\n"
    11. ...
    12. "</widget>\n";
    13. }
    14.  
    15. ...
    16.  
    17. QString AnalogClockPlugin::includeFile() const
    18. {
    19. return "mycustom.h";
    20. }
    To copy to clipboard, switch view to plain text mode 
    and run:
    Qt Code:
    1. make -f Makefile.Release
    To copy to clipboard, switch view to plain text mode 
    After this you should get a working plugin:
    Qt Code:
    1. <customwidget>
    2. <class>AnalogClockX</class>
    3. <extends>QWidget</extends>
    4. <header>mycustom.h</header>
    5. <container>0</container>
    6. <pixmap></pixmap>
    7. </customwidget>
    To copy to clipboard, switch view to plain text mode 
    This doesnt work. 100%


    Qt Code:
    1. QWidget *TestPlugin::createWidget(QWidget *parent)
    2. {
    3. return new CustomControls::CheckBox(parent);
    4. }
    5.  
    6. QString TestPlugin::name() const
    7. {
    8. return QLatin1String("CheckBox");
    9. }
    10.  
    11. QString TestPlugin::domXml() const
    12. {
    13. return QLatin1String("<widget class=\"CustomControls::CheckBox\" name=\"cb\">\n"
    14. "</widget>\n");
    15. }
    16.  
    17. QString TestPlugin::includeFile() const
    18. {
    19. return QLatin1String("checkbox.h");
    20. }
    To copy to clipboard, switch view to plain text mode 

    it gives me

    <customwidgets>
    <customwidget>
    <class>CustomControls::CheckBox</class>
    <extends>QWidget</extends>
    <header>customcontrols::checkbox.h</header>
    </customwidget>
    </customwidgets>

    and it doesn't matter what you return in function includeFile(). Header file been generated automatically from widget class
    Last edited by mister_wang; 23rd May 2015 at 12:01.

Similar Threads

  1. Custom plugin for a layout
    By cocheci in forum Qt Tools
    Replies: 2
    Last Post: 12th June 2006, 18:36
  2. Replies: 5
    Last Post: 16th May 2006, 20:38
  3. Limiting values for custom designer properties
    By high_flyer in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 12:27
  4. custom plugin designer property with out a variable?
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2006, 19:11
  5. How to initialize properties to a custom plugin widget?
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2006, 16:56

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
  •  
Qt is a trademark of The Qt Company.