Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt4-preview-feedback Archive, March 2008
Q_PROPERTY feature request


Message 1 in thread

Hi,
it would be useful to have a Q_PROPERTY extension that works on simple data 
fields by itself (kind of using implicit accessor methods) -- e.g. it would 
save some typing to be able to replace

class Something:public QObject {
	Q_OBJECT
	Q_PROPERTY(QString something READ something WRITE setSomething)
public:
	const QString &something() const { return m_something; }
	void setSomething(const QString &whatever) { m_something=whatever; }
	QString m_something;
};

with

class Something:public QObject {
	Q_OBJECT
	Q_PROPERTY(QString something IS m_something)
public:
	QString m_something;
};

or even

class Something:public QObject {
	Q_OBJECT
public:
	Q_PROPERTY(QString something READABLE true WRITABLE true); // 
<--- "something" is declared as a QString member and is accessible as 
property "something"
};

I know that most of the time having a member variable exposed directly without 
an accessor function is a bad idea, but for a few things it actually makes 
sense.

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx