QTableWidgetItem缩小 [英] QTableWidgetItem shrinking

查看:379
本文介绍了QTableWidgetItem缩小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用QTableWidgetItem时遇到问题. 我通常像这样使用QTableWidget

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);

我要写的列很窄,只有20px.我需要在其中写入2位数字,并且根据定义,我无法调整列的大小.

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.

问题在于,一旦文本与列宽重叠,它就会完全消失,而只会出现三个点(甚至什么也没有). 我可以抑制这种行为吗?我不介意是否会有1-2px的重叠/剪切,但我绝对对文字消失感到不满意.

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.

感谢您的帮助.

好吧,经过几次尝试,我必须说 TextElide 想法可行,但是,现在我面临另一个问题.有时,当QTableWiddgetItem中有更多行时,底部行将消失,只有最上面的行可见.为什么会发生这种情况的任何建议?

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?

它看起来像这样....请注意,图像之间的唯一区别是较大的字体大小.单元格绝对足够高,可以容纳所有文本. http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug1 .png http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug2.png

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

推荐答案

请参见 textElideMode 属性. this->setTextElideMode(Qt::ElideNone)将删除点.

See the textElideMode property. this->setTextElideMode(Qt::ElideNone) will remove the dots.

这篇关于QTableWidgetItem缩小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆