QTableWidgetItem shrinking

随声附和 提交于 2019-12-12 04:23:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!