Results 1 to 12 of 12

Thread: Smooth Text Scrolling

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Smooth Text Scrolling

    Hi,

    Imagine a label with a fixed size containing a single-line text string which is too wide to fit inside the label. I need to design a widget which shows the complete text string by scrolling the text string from right to left - similar to a horizontal moving banner. I realize I may be able to use a hidden horizontal scroll bar with a timer but I was hoping there was a better way to do this. Any idea would be most appreciated.

    Thanks,
    Jones

    Qt 4.5 / Qt Embedded

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Smooth Text Scrolling

    If it is only a label with text, I would do all the painting myself in a subclassed QLabel or even in a simple QWidget. Or you can alter QLabel and use QWidget::scroll() with a timer.

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

    Jones (22nd April 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Smooth Text Scrolling

    Thanks Lykurg, I ended up creating a simple QWidget and using scroll() as you suggested. Works like a charm :-)

  5. #4
    Join Date
    Oct 2010
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Smooth Text Scrolling

    can u please post ur code

  6. #5
    Join Date
    Feb 2011
    Posts
    31
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Smooth Text Scrolling

    how can i do this (adding a scroll bar to a label) from Qt designer? I see that a scroll bar widget is available from Qt designer, still, no example or help is abailable ...
    thanks

  7. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Smooth Text Scrolling

    The tread wasn't about adding a scroll bar to a label, it was about using QWidget::scroll() which is a different case... What so you exactly want? I guess you are looking for QScrollArea with a QLabel inside.

  8. The following user says thank you to Lykurg for this useful post:

    marco.stanzani (15th March 2011)

  9. #7
    Join Date
    Feb 2011
    Posts
    31
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Smooth Text Scrolling

    i solved the problem by using a Qtextedit widget which provided hori and vert scroll bars 'as nedded'

    thx

  10. #8
    Join Date
    Jul 2011
    Posts
    14
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Default Re: Smooth Text Scrolling

    Quote Originally Posted by Lykurg View Post
    If it is only a label with text, I would do all the painting myself in a subclassed QLabel or even in a simple QWidget. Or you can alter QLabel and use QWidget::scroll() with a timer.

    I want to make a label that contains rich text ,but the text is larger than the label size.
    So, I need to have a scroll bar with the label.

    How can I " alter QLabel and use QWidget::scroll() with a timer " ??
    I don't understand how to implement this

  11. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Smooth Text Scrolling

    Quote Originally Posted by Marwa Shams View Post
    So, I need to have a scroll bar with the label.
    Then it is what I said to marco.stanzani: You are looking for QScrollArea. See the detailed description and you find an example on how to use it.

  12. #10
    Join Date
    Jul 2011
    Posts
    14
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Default Re: Smooth Text Scrolling

    Quote Originally Posted by Lykurg View Post
    Then it is what I said to marco.stanzani: You are looking for QScrollArea. See the detailed description and you find an example on how to use it.
    Thank you very much

  13. #11
    Join Date
    Jul 2011
    Posts
    14
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Default Re: Smooth Text Scrolling

    I already added the label to a scroll area ..
    It works well that the scroll area has a scroll-bar vertical and horizontal
    when the height and width of the label is larger than the height and width of the scroll area .......... BUT

    the problem now with the label itself .. that the label doesn't expand its height depending on its content .
    for example:- If the height is 20 pix then one line of text only appeared .. although there is another 3 lines that doesn't appear
    So .. what is the way to make the label scaled to its content vertically??

  14. #12
    Join Date
    Nov 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Smooth Text Scrolling

    for the original post: scrolling text like a banner with Qlabel.
    go here for some answers.
    another qt centre post

Similar Threads

  1. "Smooth" Scrolling, QGraphicsView
    By nearlyNERD in forum Qt Programming
    Replies: 5
    Last Post: 25th February 2010, 17:18
  2. Get a smooth curve
    By beekeep in forum Qwt
    Replies: 2
    Last Post: 7th January 2010, 17:49
  3. Smooth lines in QGraphicsView
    By JaRo999 in forum Qt Programming
    Replies: 4
    Last Post: 27th September 2009, 15:38
  4. setMask (smooth)
    By pakulo in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 08:51
  5. automatic scrolling text edit
    By Vash5556 in forum Newbie
    Replies: 2
    Last Post: 19th March 2007, 18:32

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.