Results 1 to 2 of 2

Thread: Issue in using dynamic property in QT inherited classes.

  1. #1
    Join Date
    Nov 2009
    Posts
    60
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Issue in using dynamic property in QT inherited classes.

    Hi want to add a new Q_PROPERY into my subclass and use this in my application.

    I tried the following test programe.

    Scenario 1:
    1. created the following class as a subclass of QPushButton.

    class eSSlButtonublic QPushButton
    {
    Q_OBJECT
    // Q_PROPERTY(char val READ getVal)
    public:
    eSSlButton(QWidget * parent = 0);
    ~eSSlButton();
    void keyPressEvent( QKeyEvent *e );
    };

    definition for the above class

    eSSlButton::eSSlButton(QWidget * parent):QPushButton(parent)
    {

    }

    void eSSlButton::keyPressEvent( QKeyEvent *e )
    {

    printf("In side dbasbd %c %x\n",QObject:roperty("val").toChar(),e->key());
    }

    eSSlButton::~eSSlButton()
    {

    }

    2. Now added the properties 'val' as char type from property window of Qt Designer.

    3. Now when I run the executable it gives a segmentation fault.


    Kindly let me know how to set the dynamic property for the subclass with the help of QT Designer.

    Thanks in Advance

  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: Issue in using dynamic property in QT inherited classes.

    You can't define new properties using the designer. You have to code them yourself. Which is your commented line and then you must of course provide the setter and getter function.

Similar Threads

  1. Change Stylesheet Using Dynamic Property
    By stefanadelbert in forum Qt Programming
    Replies: 4
    Last Post: 26th August 2010, 07:48
  2. Inherited Palette Problem
    By zgulser in forum Qt Programming
    Replies: 7
    Last Post: 10th March 2010, 10:09
  3. Inherited Style Sheet
    By johnmauer in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2010, 21:07
  4. Dynamic property and stylesheets
    By aamer4yu in forum Qt Programming
    Replies: 10
    Last Post: 18th November 2009, 18:26
  5. How QMessageBox can be inherited.
    By rajveer in forum Qt Programming
    Replies: 40
    Last Post: 10th September 2008, 14:27

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.