Results 1 to 4 of 4

Thread: QLabel - visible text function or something else

  1. #1
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QLabel - visible text function or something else

    hello,

    I'm making something like music player and I'm using QLabel to display the track title.
    Sometimes the track title is long and the result is:


    I must create algorithm to show it all in parts. I want to ask: is there a function that return me only the visible text?

    thanks all

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLabel - visible text function or something else

    Not sure of any such function.
    I guess u want to show the whole text.
    Would suggest 2 solutions -
    1) Use setToolTip() to display the whole text
    2) Inherit QLabel and make the text scrolling. Its easy. Set a fixed no of chars to display. Now display the string - fullString.mid(ith_position,no_of_chars_to_displaY ) using a QTimer .

    Hope this helps

  3. The following user says thank you to aamer4yu for this useful post:

    john (20th April 2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLabel - visible text function or something else

    Yes, the scrolling is good method, but I don't know how many chars to display, because my form is resizable. May be I need to create funkction that calculate the chars from the label width.

    Thank you...

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QLabel - visible text function or something else

    There is such a function. Take a look at QFontMetrics::elidedText().

  6. The following user says thank you to wysota for this useful post:

    john (25th April 2008)

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.