Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QLabel to stretch with text
Qt 6.11 is out! See what's new in the release blog

QLabel to stretch with text

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TimJohnson
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tzander
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TimJohnson
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jens
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved