Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved How to show the long text on a label that just show the latest part.

    General and Desktop
    3
    8
    391
    Loading More Posts
    • 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.
    • Mihan
      Mihan last edited by

      e.g. a label's width is 100 (pixel) ,a text's width is 200 (pixel), i want the label just show last 100 pixel content of the text, the label's size policy is fixed. Now it just shows the first 100 pixel and also without ellipsis to remind it has other 100 pixel. So how to do that ,thank you.

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @Mihan last edited by

        hi @Mihan

        take a look at this elided label example:

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

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply Reply Quote 5
        • Mihan
          Mihan last edited by

          dose it means it also can elide the content like
          e.g.
          abcdefg -> ...efg
          not
          abcdefg -> abc...

          1 Reply Last reply Reply Quote 0
          • Kent-Dorfman
            Kent-Dorfman last edited by

            not something I've ever had to do so there is probably a better way...but, I would most likely write the text to a bitmap, clip the bitmap to the relevant window, and then display it in the widget.

            Mihan 1 Reply Last reply Reply Quote 0
            • Mihan
              Mihan @Kent-Dorfman last edited by

              @Kent-Dorfman also I have an idea that usedrawText() on a widget like you said, but i think it is cumbersome XD. So I want to get a better way to do that~

              Kent-Dorfman 1 Reply Last reply Reply Quote 0
              • Kent-Dorfman
                Kent-Dorfman @Mihan last edited by

                @Mihan
                I wouldn't be too concerned...unless you're in a really resource constrained system.

                Mihan 1 Reply Last reply Reply Quote 0
                • Mihan
                  Mihan @Kent-Dorfman last edited by Mihan

                  @Kent-Dorfman Yep, running on ARM. BTW, could you tell me how to make a LineEdit's text cursor always is visible. I found something in source code ,

                  if (QApplication::keypadNavigationEnabled()) {
                          if (e->type() == QEvent::EnterEditFocus) {
                              end(false);
                              d->setCursorVisible(true);
                              d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
                          } else if (e->type() == QEvent::LeaveEditFocus) {
                              d->setCursorVisible(false);
                              d->control->setCursorBlinkPeriod(0);
                              if (d->control->hasAcceptableInput() || d->control->fixup())
                                  emit editingFinished();
                          }
                      }
                  

                  it's in QLineEdit's event(), so how can I use this setCursorVisible(bool) ?

                  Mihan 1 Reply Last reply Reply Quote 0
                  • Mihan
                    Mihan @Mihan last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post