Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT class, which cut texts
Forum Updated to NodeBB v4.3 + New Features

QT class, which cut texts

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 379 Views
  • 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
    TomNow99
    wrote on last edited by TomNow99
    #1

    Hi,

    A few weeks ago I find perfect class in Qt, which do:

    I have some long text like "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", and my QLabel has fixed Width and it's smaller
    than size of my long text ( in pixels ). I would like to see in QLabel something like:

    "AAAA...AAAA".

    I know that is possible, but I don't remember the name of this class...

    EDIT:

    In this function in that class I have to add param: the size in pixels.

    EDIT2: Maybe QFontMetrics - I have to check that

    JonBJ 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Maybe this example helps: https://doc.qt.io/qt-5/qtwidgets-widgets-elidedlabel-example.html

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3
      • T TomNow99

        Hi,

        A few weeks ago I find perfect class in Qt, which do:

        I have some long text like "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", and my QLabel has fixed Width and it's smaller
        than size of my long text ( in pixels ). I would like to see in QLabel something like:

        "AAAA...AAAA".

        I know that is possible, but I don't remember the name of this class...

        EDIT:

        In this function in that class I have to add param: the size in pixels.

        EDIT2: Maybe QFontMetrics - I have to check that

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @TomNow99
        And https://doc.qt.io/qt-5/qt.html#TextElideMode-enum, https://doc.qt.io/qt-5/qfontmetrics.html#elidedText.

        https://itqna.net/questions/14614/it-possible-use-elide-qlabel derives from QLabel, while the Qt example derives from QFrame. The last answer there is just 4 lines rather than a whole class. As you please.

        1 Reply Last reply
        3
        • T Offline
          T Offline
          TomNow99
          wrote on last edited by
          #4

          @VRonin @JonB
          Thank you :)

          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