QLabel to stretch with text



  • Hey guys, I have whats probably a stupid question. I've followed a tutorial to implement my own label type successfully, but when I tried it I could see only one character, because the QLabel does not stretch with the text assigned when I assign text to the QML element for it. The only fix I've had which displays the whole of whatever I assign so far is to put a whole load of spaces in the QLabel's text property from the C++

    @ mLabel = new QLabel(QString(" "));@

    I couldn't see any properties or methods on the docs that seemed applicable to my situation, or maybe I missed something crucial

    Hopefully I explained everything properly.

    Thanks for any help you can offer me!



  • Use the Text item in QML, not the QLabel (widget) based class.
    You use that from QML directly, not from C++



  • I would, but as I said, I was just doing this as an exercise to learn about extending QML via C++ :P



  • You do not really provide enough context to solve the issue. QLabel should never be used inside a qt quick Item. If you are indeed trying to use a QLabel in a QQuickPaintedItem, it might be that your QLabel size is simply not connected to the size of the QQuickItem and stays fixed size never allowing it to expand to its full size.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.