PDA

View Full Version : QItemDelegate and Scrolling



SElsner
5th March 2010, 21:21
Hello,

in a QTableView I have a column with text, which should be scrollable. I know I need a Delegate to do this and I have tried several approaches with QPlainTextEdit:

+ setting the widget with setIndexWidget. This does not seem to work, its not painting anything (and Its very slow!)
+ using somthing like QApplication::style()->drawControl(QStyle::CE_ProgressBar, opts, painter, 0); but there is no CC or CE for a Plain Text Widget (taken from http://www.qtcentre.org/threads/2330-How-to-show-progess-in-a-QTreeView-item)
+ I have tried using paint, drawFrame and render on QPlainTextWidget, but no luck so far

I have read all posts here and on google which could provide the smallest hint on how to solve this. But seems I miss something really basic.... Perhaps sombody can point me to some other possible solution.

Thanks

Sebastian

waynew
6th March 2010, 16:09
I'm not sure what you are trying to do - scroll up and down the table or within a cell.

In my QTableView, if I doubleclick in a cell with more text in it than shows in the view, it automatically expands to show all of the text as long as the mouse cursor is over the cell.

SElsner
6th March 2010, 18:02
Yes i try to provide scrollbars in a table cell while in QDisplayRole. did you get your behaviour for free or did you have to code it? How does an user know that there is more Text than they can see? Ill try this tomorrow. Thanks for the heads up. Anyone else got a suggestion?

toutarrive
7th March 2010, 15:29
If you want to have a custom behaviour for scrolldowm you have to subclass QStyle ( QStyle controls everything in terms of display) .
But before doing so, can you tell us where the default behaviour doesn't suit your needs .

SElsner
8th March 2010, 12:08
Hmm... which default behaviour? I am not seeing anything what you or waynew described. The text is just cut off not matter how much i double click or leave the mouse over the cell.

To make myself clear:
The problem: Too much text in one cell.
The desired solution: scrolling text in the cell (in display role), but I'm open for other ideas