Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get correct QGraphicsItem
Forum Update on Monday, May 27th 2025

Get correct QGraphicsItem

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    onurozcelik
    wrote on 27 Aug 2010, 12:57 last edited by
    #1

    I have a custom class derived from QGraphicsItem. In that class I have private data member which is QGraphicsSvgItem. In my custom class constructor I am creating a QGraphicsSvgItem and its parent as my custom class. Below what I did.

    @class CustomItem : public QGraphicsItem
    {
    private:
    QGraphicsSvgItem *svgItem;
    }

    CustomItem::CustomItem()
    {
    svgItem = new QGraphicsSvgItem(fileName,this);
    }
    @

    Besides this I have another class(CustomItem2). With this class I am filtering CustomItem events.(I set all my CustomItems parent as CustomItem2)
    When CustomItem2 filters an event which belongs to CustomItem i can't get information about CustomItem because the watched object returns as QGraphicsSvgItem.
    But i want the object return as CustomItem.
    How can I solve this?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on 28 Aug 2010, 14:39 last edited by
      #2

      You can solve this by making CustomItem a QGraphicsSvgItem:

      @ class CustomItem : public QGraphicsSvgItem
      {
      ...
      };

      CustomItem::CustomItem(QGraphicsItem *parent) :
      QGraphicsSvgItem(fileName, parent)
      {

      }@

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0

      1/2

      27 Aug 2010, 12:57

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved