Results 1 to 5 of 5

Thread: QLineEdit and QScrollBar

  1. #1
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    69
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default QLineEdit and QScrollBar

    hi,
    Can anyone tell me how to connect a scrollbar to a lineedit manually(as QLineEdit doesnot inherit QScrollView as QTextEdit do).

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLineEdit and QScrollBar

    Quote Originally Posted by Sarma
    hi,
    Can anyone tell me how to connect a scrollbar to a lineedit manually(as QLineEdit doesnot inherit QScrollView as QTextEdit do).
    Umm? You want a horizontal scroll bar?
    How about try adding the line edit widget in a scroll view?

  3. #3
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    69
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: QLineEdit and QScrollBar

    Yes I want a horizontal scrollbar. I tried it the way you said(adding lineEdit to scrollview).But it is making the GUI look nasty as it is occupying more space than intended to it.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLineEdit and QScrollBar

    In my opinion the thing you are trying to do is a bit wicked..
    I think it is very common and normal behaviour for single line edit items (and I mean overall, not just Qt), that no additional scroll bars appear when user types more text than fits in the line edit.

    Of course you can do that, it only might need a whole lot of custom code. You might need to use a separate scroll bar and a lot of signal-slot connections and/or events for setting the cursor position or drawing a different part of the line edit when the scroll bar is changed. And same thing goes for updating the scroll bar. And while writing the earlier two sentences, another problem came to my mind. Should the cursor position change when scrolled or not? If not, what happens when the text cursor is at the end and the user scrolls to the beginning (by the scrollbar)? Then the movement of the text cursor position should change the scrollbar position back to the end right?

    In other words, the cursor movement should be a sufficient way to "navigate" inside a QLineEdit.
    If not (eg. the line edit allows too much text and the navigating by a cursor becomes awkward), consider using a QTextEdit...
    Last edited by jpn; 8th March 2006 at 07:35.

  5. #5
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    69
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: QLineEdit and QScrollBar

    Of-course, what you said is correct. I have used a tooltip which shows the text in the lineedit at any time(when mouse is placed over it). well, connecting a scrollbar is just a requirement and now, tooltip is its enhancement.

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.