Results 1 to 2 of 2

Thread: Exposing custom widget properties

  1. #1
    Join Date
    Jul 2010
    Posts
    10
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Exposing custom widget properties

    Is there a way to have custom widget properties shown in Qt Creator ( in this section http://imgur.com/TJx6F.png ) just using promotion? I find that the plugin method is quite tedious and promotion is so easy, I'd love to get them from just promoting.

    If the only way to get these properties into Qt Creator is with plugins, is this the correct way of exposing the price and name variables?

    Qt Code:
    1. class ServiceButton : public QPushButton
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY( QString m_sServiceName READ getServiceName WRITE setServiceName DESIGNABLE true );
    5. Q_PROPERTY( float m_fPrice READ getPrice WRITE setPrice DESIGNABLE true );
    6. public:
    7. ServiceButton(QWidget *parent = 0);
    8. public slots:
    9. QString getServiceName();
    10. void setServiceName( QString s );
    11. float getPrice();
    12. void setPrice( float f );
    13. protected:
    14. QString m_sServiceName;
    15. float m_fPrice;
    16. };
    To copy to clipboard, switch view to plain text mode 

    Thanks

    P.S. is there any Qt type of float like "QDecimal", "QFloat" or whatever?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Exposing custom widget properties

    You have to write your own plugin and float is fine since it is a generic type such as int. For a simple pugin see http://doc.trolltech.com/4.6/designe...getplugin.html

  3. The following user says thank you to Lykurg for this useful post:

    Plixil (30th July 2010)

Similar Threads

  1. QT4 custom designer plugin properties ignored
    By Intangir in forum Qt Programming
    Replies: 7
    Last Post: 23rd May 2015, 11:56
  2. Replies: 7
    Last Post: 21st January 2010, 12:45
  3. QComboBox Custom Widget has missing designer properties
    By vieraci in forum Qt Programming
    Replies: 5
    Last Post: 9th December 2009, 13:30
  4. Replies: 5
    Last Post: 16th May 2006, 20:38
  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

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.