[Qt-interest] Best way to combine QGraphicsItem and qobject_cast
Malyushytsky, Alex
alex at wai.com
Tue Jan 4 04:11:02 CET 2011
Consider using setData:
void QGraphicsItem::setData ( int key, const QVariant & value )
Alex
-----Original Message-----
From: qt-interest-bounces+alex=wai.com at qt.nokia.com [mailto:qt-interest-bounces+alex=wai.com at qt.nokia.com] On Behalf Of NoRulez
Sent: Monday, January 03, 2011 6:56 PM
To: Qt Interest MailingList
Subject: [Qt-interest] Best way to combine QGraphicsItem and qobject_cast
Hi,
I've several QGraphicsItems such as QGraphicsRectItem.
Now I want to have a setId() and a getId() function for each item.
So, what is the best way to do so?
As the result I want to do something like
foreach (QGraphicsItem *pItem, pScene->selectedItems()) {
qDebug() << qobject_cast<MyBaseClass*>(pItem)->getId();
}
My idea was to add a class and inherit from it:
class MyBaseClass : public QObject {
Q_OBJECT
public:
void setId(const QString&);
QString getId() const;
};
class MyItem : public QGraphicsRectItem, public MyBaseClass {
};
Thanks in advance
Best Regards
NoRulez
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list