问题
I have an issue usign QTableWidgetItem. I normally use the QTableWidget like this
this->setItem(i, j, new QTableWidgetItem());
this->item(i, j)->setText(string);
The column I'm writing to is narrow, only about 20px. I need to write 2 digits in there and from the definition I cannot resize the column.
The problem is that once the text overlaps the column width, it totally disappears and only three dots (or even nothing) appear instead. Can I suppress this behavior? I dont mind if there will be 1-2px overlap/clip, but I'm definitely not comfortable with the text disappearance.
Thanks for any help.
EDIT:
Well, after a couple of tries, I must say that the TextElide think works, however, now I face another problem. Sometimes, when there are more lines in the QTableWiddgetItem, the bottom lines just disappear and only the top one is visible. Any suggestions why this may happen?
EDIT 2:
It looks like this....note that the only difference between the images is a bigger font size. The cells are definitely high enough to containt all the text. http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug1.png http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug2.png
回答1:
See the textElideMode property. this->setTextElideMode(Qt::ElideNone)
will remove the dots.
回答2:
Have you tried setting the sizeHint of the item? See this
来源:https://stackoverflow.com/questions/5781589/qtablewidgetitem-shrinking