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. [Solved] Dragging a QGraphicsItem over another is distorting the other QGraphicsItem's color
QtWS25 Last Chance

[Solved] Dragging a QGraphicsItem over another is distorting the other QGraphicsItem's color

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • A Offline
    A Offline
    amban
    wrote on last edited by
    #1

    Hi.
    I have implemented a QGraphicsRectItem inside a QGraphicsPolygonItem. The QGraphicsRectItem item displays a color.
    When i slide one QGraphicsPolygonItem over the other, the color is getting distorted and becoming white(default color of it's parent i.e. QGraphicsPolygonItem)

    I have implemented following -
    @
    void DiagramItem::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget )
    {
    ……

    if (option->state & QStyle::State_Selected)
    {
    

    …..
    scene()->update();
    }
    }
    @

    where DiagramItem is a subclass of QGraphicsPolygonItem.
    This tremendously increases my CPU utilization....

    What is a probable solution to this problem ?

    Thanks.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      I don't really see how your code snippet relates to your problem. Maybe you could post a more complete code sample?

      I find it interesting that you call scene()->update(); within paint - couldn't that cause the CPU utilization?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        amban
        wrote on last edited by
        #3

        I recognized my error. I created a public function which mocks functionality of paint() in QGraphicsRectItem and then call the dummy paint() from QGraphicsPolygonItem.

        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