PDA

View Full Version : QTableWidgetItem Text Editing



ToddAtWSU
6th March 2008, 20:22
I have a QTableWidget set up the way I want it and I have it set up so I cannot edit the first column of text and can edit the second column of text.

Whenever I edit the text in the 2nd column of QTableWidgetItems, if the text exceeds the width of the column, the text on the left is shifted over so I cannot see it and can keep entering text on the right. How do I get it to work so that it displays a 2nd line while I edit it and then once I leave the cell or hit Enter, it moves it back to the single line with part of it invisible. When I edit text, I want it to work like a QTextEdit in that it will wrap to another line, but then when I leave the cell to display like a QLineEdit. I have tried QTableView::setWordWrap( true ) but that didn't work. Thanks!

jpn
6th March 2008, 20:38
I guess you could make a custom delegate whose createEditor() returns a QTextEdit instead of QLineEdit.

majgis
17th March 2009, 02:23
ToddAtWSU,

I need to do exactly the same thing. Did this method work for you? Do you have an example handy?