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
Qt 6.11 is out! See what's new in the release blog

Get correct QGraphicsItem

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.6k Views 1 Watching
  • 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 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 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

      • Login

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