[Qt-interest] Best way to combine QGraphicsItem and qobject_cast
NoRulez
norulez at me.com
Tue Jan 4 11:14:38 CET 2011
Isn't there such a way, because I have already a class which I want to use.
Best Regards
NoRulez
Am 04.01.2011 um 04:11 schrieb "Malyushytsky, Alex" <alex at wai.com>:
> 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.”
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list