PDA

View Full Version : QPlainTextEdit and its size policy



Lykurg
9th March 2010, 09:40
Hey,

I need a QPlainTextEdit which behaves exactly like a QLabel regarding its size policy (including dynamic size change). After playing around with different policies I came to the conclusion, that it is not possible (at least not so easy). The text edit is always much bigger that a corresponding label...

Do you have any hint on how that could be achieved?


Thanks,
Lykurg

For clarification: Currently I have different widgets is a float layout. These widgets contains labels which accept multiple "text drops" which are joined to one big string. This works quite nice. But now I need some functionality of a text edit. But that should not destroy the layout.
The function I need is, that I am able to right click in the label and get the underlying word and a custom variable stored with that particular word. (A solution with a look up hash etc. is not possible since the strings are not always unique)
One solution for my problem is to subclass QLabel and add a private QTextDocument which does all the painting. But before I go that way, maybe someone knows a better/easier/faster solution.