社区
Qt
帖子详情
怎样定义QTableWidget中的CellWidget在table中的对齐方式?
高维橘子
2013-12-16 11:19:13
在QTableWidget中添加了一个CellWidget,是QLabel,其中Label上还有文字。
在label上设置了文字的对齐方式是Qt::AlignCenter,但是不知道怎么设置这个CellWidget在Table的格子里的对齐方式。
请问,怎么设置CellWidget在QTabelWidget中也是Qt::AlignCenter?
...全文
1015
4
打赏
收藏
怎样定义QTableWidget中的CellWidget在table中的对齐方式?
在QTableWidget中添加了一个CellWidget,是QLabel,其中Label上还有文字。 在label上设置了文字的对齐方式是Qt::AlignCenter,但是不知道怎么设置这个CellWidget在Table的格子里的对齐方式。 请问,怎么设置CellWidget在QTabelWidget中也是Qt::AlignCenter?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
wxiuqing856
2015-01-06
打赏
举报
回复
没有找到直接的接口,不过,可以自己模拟一下: 在cellwidget的外层添加一层透明窗体,在这层透明窗体上添加布局,将cellWidget放入布局中,对布局进行对齐设置。 示例代码: QWidget *translateWidget = new QWidget(m_ptablewnd); translateWidget->setObjectName("translateWidget"); translateWidget->setStyleSheet("background-color:rgba(0,0,0,0)"); QHBoxLayout *hbl = new QHBoxLayout(); hbl->setSpacing(0); hbl->setContentsMargins(0,0,0,0); hbl->setMargin(2); translateWidget->setLayout(hbl); QPushButton *button = new QPushButton (translateWidget); hbl->addWidget(button,1,Qt::AlignCenter); button->setToolTip("Hello"); button->setIcon(QIcon(a.png)); button->setFixedSize(64,64); hbl->addWidget(button); QTableWidget *tableWidget = QTableWidget(); tableWidget->setRowCount(1); tableWidget->setColumnCount(1); tableWidget->setCellWidget(0,0,translateWidget);
高维橘子
2013-12-16
打赏
举报
回复
引用 2 楼 lion_kangaxx 的回复:
似乎没有一蹴而就的办法,保持宽度一致应该可以吧?看看其他人有没有办法
谢谢!我也没有找到。
l4kangaxx
2013-12-16
打赏
举报
回复
似乎没有一蹴而就的办法,保持宽度一致应该可以吧?看看其他人有没有办法
Q
Table
Widget
控件使用总结
QTbale
Widget
是QT对话框设计
中
常用的显示数据表格的控件。 学习
Q
Table
Widget
就要首先看看Q
Table
View控件(控件也是有”家世“的!就像研究人一样一样的),因为
Q
Table
Widget
继承于类Q
Table
View。 两者主要区别是...
PyQt5高级界面控件之
Q
Table
Widget
(四)
Q
Table
Widget
是Qt程序
中
常用的显示数据表格的控件,类似于c#
中
的DataGrid。
Q
Table
Widget
是Q
Table
View的子类,它使用标准的数据模型,并且其单元数据是通过
Q
Table
Widget
Item对象来实现的,使用
Q
Table
Widget
时就需要...
Qt开发:
Q
Table
Widget
的介绍和使用
本文主要介绍Qt
中
Q
Table
Widget
的常用方法。
在
Q
Table
Widget
中
添加QCheckBox并居
中
//将
widget
放到
table
中
//采取下面
方式
获取 if (Q
Widget
*w = ui->
table
Widget
_IdentifiedPrimitives->
cell
Widget
(row, column))//先获取
widget
{ QCheckBox * checkBox = qobject_cast*>(w->children().at(1));...
QT
Q
Table
Widget
用法总结
Q
Table
Widget
是QT程序
中
常用的显示数据表格的空间,很类似于VC、C#
中
的DataGrid。说到
Q
Table
Widget
,就必须讲一下它跟QTabelView的区别了。
Q
Table
Widget
是Q
Table
View的子类,主要的区别是Q
Table
View可以使用自
定义
的...
Qt
21,480
社区成员
26,692
社区内容
发帖
与我相关
我的任务
Qt
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
复制链接
扫一扫
分享
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章