Nominate our 2022 Qt Champions!

[Solved] Compress QLabel

  • Solve: I put a button on the widget, which show or hides the labels. I needed a rapid solution: it seems to be enough fast and pretty.

    Hi Folks,

    I have an UI app with some widgets, and I would like to place into that an QLabel. The label will display some formatted text, which is wrapped into several line. I would like the following: normaly, the QLabel should display only the first line of text. When the mouse points to the label, it should expand itself, so the whole text will be visible.
    How can I set the this behavioral for the QLabel?


  • I am not an expert in Qt. In fact I am a beginner myself. However I have done similar things using .NET. After looking at the QLabel documentation my guess would create your own class that inherits QLabel and overrides the mouseMoveEvent method. In your override you could change the size and contents of the label as needed for your program. The documentation also suggests that this will not work unless you enable mouse tracking. You would have to research how to accomplish that.

  • hii.

    Find some clue from following lilnk

    hope it helps.

Log in to reply