Qt World Summit: Register Today!

Qt QGraphicsProxyWidget hiding other QGraphicsProxyWidgets[SOLVED]

  • I'm working on a Slotmachine with QGraphicsScene and -View and I'm close to the end of that project in my studies. But now I want to add a small rect to the winning-lines that shows the amount of won credits in that line. The rect is a QLabel in a QGraphicsProxyWidget. I don't know if thats the best way to solve this problem but I'm not able to find a better solution at the moment. I'm setting the proxyWidget to not visible in the constructor of the label but when I'm setting this proxyWidget to visible other proxyWidgets in the scene disappear. And I just dont understand why. It's not hiding every proxyWidgets.

    to the picture

    As you can see on the picture there's a red rect in the middle of the first square of the winning line. This is causing the problem. It is hiding the lower white border which is a QGraphicsPixmapItem and the first of the normally three QGraphicsProxyWidgets at the bottom, stake(this is not visible), last gain(letzter Gewinn), credit(Guthaben). I don't know why its not hiding the other Widgets on the bottom because they are all equal. As you can see its not hiding the complete lower border. I just don't know why this happens and why it just happens to the lower border and the left widget on the bottom and not to any other elements. I just don't know how to fix a problem like that.

    It's a bit long to read but I don't know how to really describe the problem or how I could show you in the Code. I hope someone could help me.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Why do you need QGraphicsProxyWidget ?

  • I don't know how I should add in that Rect with the right value without a Qlabel and without a QProxyWidget.

  • Lifetime Qt Champion

    Why not use a QGraphicsRectItem ?

  • how could I add the text to a QGraphicsRectItem?

  • Lifetime Qt Champion

    Then maybe QGraphicsTextItem ?

  • oh this could be a good idea. forgot about that. i'm going to try that thank you :)

  • how do i change the text of a QGraphicsTextItem? I have to set it in the game, not when im initializing the item.

  • Lifetime Qt Champion

    Keep a pointer to the item and then call setPlainText on it.

  • thank you SGaist for your help, that was the solution I was looking for! Thats pretty nice! Thank you and have a nice day!

Log in to reply