Answer the question
In order to leave comments, you need to log in
How to make a QGraphicsItem that can be both an image and text?
Hello. Faced such a problem. I want to make a graphic element, which can be either a picture or text. That is, this element has the setting "Display as an image" and I want either an image or text to be displayed depending on this.
Now my count. the element is inherited from QGraphicsPixmapItem, but I never found a way to make it so that I can write text to it.
How can I combine the ability to display both text and an image? Shouldn't it inherit from QGraphicsPixmapItem and QGraphicsTextItem?
Or maybe I need to inherit my QGraphicsItem, in which I will have to implement all this? Then tell me, please, an approximate procedure, because I could not find anything similar in Google.
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
QLabel can "be" either a picture or text
https://forum.qt.io/topic/82420/show-picture-using...
Shouldn't it inherit from QGraphicsPixmapItem and QGraphicsTextItem?- why not? You clearly have two different tasks that must be performed, however, by one class. But inside they will still remain different.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question