PDA

View Full Version : QLineEdit and QScrollBar



Sarma
8th March 2006, 05:16
hi,
Can anyone tell me how to connect a scrollbar to a lineedit manually(as QLineEdit doesnot inherit QScrollView as QTextEdit do).

jpn
8th March 2006, 06:23
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?

Sarma
8th March 2006, 07:09
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.

jpn
8th March 2006, 07:31
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... ;)

Sarma
8th March 2006, 08:07
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.