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. Painting issues with QT5
Forum Updated to NodeBB v4.3 + New Features

Painting issues with QT5

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

    Hello,

    While porting my app in Qt5, i have several problems with the call of the method paint in QGraphicsItem by example.

    Example : i have a QGraphicsItem which works as a button.
    I catch the signal pressed() , i change the button's color but the method paint is not called (i tried to force it by calling update() but it doesnt work too). So the new color never prints.
    Then i catch the signal released() , I set the oldest color.

    So in my loop, the button's color never changes.

    Any idea how to solve this problem? I hadn't this problem with Qt 4.6 but i setted the graphicssystem as raster and it isnt possible anymore in QT5.

    Thanks.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Dunno about QGraphicsItem, but in SceneGraph you need to set itemHasContents property to true, otherwise the update will not be executed.

      It looks like a porting bug, though, I think Qt devs would be interested to see it in the "bugtracker":https://qt-project.org/wiki/ReportingBugsInQt, together with a minimal example reproducing the issue.

      (Z(:^

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sl.sy.ifm
        wrote on last edited by
        #3

        Would be nice if you could give some more information
        ... e.g. what do you mean by "changing color", QGraphicsItem has no method for doing this ... so there must be some subclassing involved (e.g. QAbstractGraphicsShapeItem or a subclass of it like QGraphicsRectItem ... or some own implementation)

        btw. I think some behavior of QGraphics... changed around 4.6/4.7 ... so maybe it's not even a 4->5 issue, would be good if you could try your old code build and run with qt4.8 ...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          artif27
          wrote on last edited by
          #4

          In fact, i have a classe ButtonItem which inherits QGraphicsItem (so the method paint ...) but the event paint is never called between the event pressed and the event released. So there is no color changes.

          My log :
          ButtonItem::OnPress()
          END ButtonItem::OnPress()
          ButtonItem::OnReleased()
          END ButtonItem::OnReleased()
          ButtonItem::paint()
          ....

          1 Reply Last reply
          0
          • A Offline
            A Offline
            artif27
            wrote on last edited by
            #5

            if I click on the button and if i do alt+tab in order to change window, the paint is called and my color changes before the released event. Strange!

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sl.sy.ifm
              wrote on last edited by
              #6

              I think you have to add a call to "update()" in your onPress-handling and onRelease-handling ... maybe it was called automatically in older qt4 versions
              ... as I wrote in last post, there was some event-handling changed in 4.6 or 4.7 (I guess they reducing events for better performance in Quick1 ... but it broke my QGraphics-based Editor back then )

              ... btw. while trying this I recognized that onRelease is only called if not calling onPress-function of baseclass (that's also a behavior, I wouldn't have expected ...)

              1 Reply Last reply
              0
              • A Offline
                A Offline
                artif27
                wrote on last edited by
                #7

                In fact , it tried to call update() but it didnt work till i see we use a GraphicsProxyWidget in order to link with a QGraphicsItem . We called the function setCacheMode(QGraphicsItem::ItemCoordinateCache). So the method paint sometimes was never called.

                But now i have problems in printing some other object by deleting the call of this function. lol

                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