PDA

View Full Version : Auto Scrolling QListWidgetItem



wakkaow
21st January 2012, 12:32
Hello All,
In my program I have used a QlistWidget . Sometimes Item string are longer the space provided.
So I need to scroll my Text to and fro in order to show the full item string.


Please Help

blueSpirit
21st January 2012, 15:59
Hmmm... I just wrote a sample program, and there the scroll bars appeared. So what's your problem exactly?


int main( int argc, char *argv[] )
{
QApplication a(argc, argv);

QListWidget oListWidget;
new QListWidgetItem( QObject::tr(" sdlfjksdfsdlfkjs dflksjd lfksjdfl ksdjf sdf"), &oListWidget);
oListWidget.show();

return a.exec();
}


Otherwise you can wrap a QScrollArea around: http://doc.qt.nokia.com/4.7/qscrollarea.html#details

wakkaow
23rd January 2012, 03:47
Actually I dont need a scroll bar.
I need when I select a particular Item of the QList Widget, if its length is longer than the space provided it should move to and fro to show the full string

I hope i could xplain

Thnx

ChrisW67
23rd January 2012, 23:44
Like the HTML marquee (http://en.wikipedia.org/wiki/Marquee_element) element along with all its failings?

d_stranz
24th January 2012, 00:35
Let's just suppose that, for whatever insane reason, one actually wanted to implement this. I'm trying to guess at how one might go about it.

My initial idea is to implement a QLineEdt delegate that, when displayed, would include a timer that would step the cursor position along one character at a time, either forward or backward, each time it fired. Would that be feasible?

ChrisW67
24th January 2012, 00:49
The problem I see is that when you are not editing the cell in the QTableView there is no widget that you can do this with. When you are editing the cell you want a standard QLineEdit rather than trying to edit a bouncing message ;)

You could render the text with a (sometimes) variable offset in the delegate paint() routine, but the delegate paint routine would only be called when it is required to repaint a particular cell (value changes or scrolls into view). The trick would be how to get this to fire periodically without forcing the redraw (update() or repaint()) of the whole QTableView. Not obvious to me.

d_stranz
24th January 2012, 02:20
When you are editing the cell you want a standard QLineEdit rather than trying to edit a bouncing message

Ah, yes, very true. With my solution it would be like editing karaoke. And you certainly wouldn't want every cell to be continuously scrolling back and forth, only the selected one.

Never mind - anything that I can envision would be hideous.

wysota
24th January 2012, 03:09
The trick would be how to get this to fire periodically without forcing the redraw (update() or repaint()) of the whole QTableView. Not obvious to me.
It's not a big deal. One calls update() on the view's viewport using QAbstractItemView::visualRect(). Provided one uses Qt4 despite that his profile says otherwise (yeah, I know there is no QListWidgetItem in Qt3).

The epilepsy-warning issue still remains, though. I can't even think what it would look like if the text was spinning in multiple cells at once.

ChrisW67
24th January 2012, 04:41
Ahh, you live and you learn.