View Full Version : How to Use Q_PROPERTY
mitesh_modi
20th June 2006, 12:14
Hi All,
I am a newbie to QT and using QT4.1.1 on Ubuntu-linux. i have to port C#'s class porperties in QT. so i think Q_PROPERTY might be useful. so any one let me know how to use Q_PROPERTY and it is great help if i can get sample example.
Thanks,
Mitesh.
munna
20th June 2006, 12:21
This (http://doc.trolltech.com/4.0/properties.html) should help you
e8johan
20th June 2006, 13:34
This could also help: http://qt4.digitalfanatics.org/tiqt/chapter-2.html .
jacek
20th June 2006, 14:28
And this (http://www.qtcentre.org/forum/f-qt-programming-2/t-custom-plugin-designer-property-with-out-a-variable-1252.html).
mitesh_modi
20th June 2006, 14:48
Thanks All for quick reply.
I have a one more question how can i use this property from other class which derive this class.
like
class NumberHolder : public QObject
{
Q_OBJECT
Q_PROPERTY( int number READ number WRITE setNumber )
public:
NumberHolder( int value = 0 );
~NumberHolder();
int number() const;
void showNumber() const;
public slots:
void setNumber( int value );
private:
int m_value;
};
class DeriveClass : NumberHolder
{
private:
int der_no;
public:
void assignProp()
{
der_no=NumberHolder.number; //HOW CAN I USE PROPERTY?
}
};
Again Thanks for your help.
Mitesh
jacek
20th June 2006, 14:58
In this case you just have to use the proper method:
void assignProp()
{
der_no = number();
}
mitesh_modi
20th June 2006, 15:08
Hi jacek,
Thanks for quick reply,
Thats right i can use method but then what is use of Q_PROPERTY? means i am missing some knowledge regarding Q_PROPERTY. I think that because of Q_PROPERTY macro one sholud not get the knowledge of class members and do get set of property defined in a class.
Can you briefly give what is the exact use of Q_PROPERTY.
Thanks,
Mitesh..
jacek
20th June 2006, 15:49
Can you briefly give what is the exact use of Q_PROPERTY.
You can use QObject::property() and QObject::setProperty() to change the value of given property without knowing anything about the object.
http://www.qtcentre.org/forum/f-newbie-4/t-enlighten-me-on-the-use-of-q-property-1596.html
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.