• 5224阅读
  • 1回复

[提问]TableWidget [复制链接]

上一主题 下一主题
离线yuan0302
 
只看楼主 倒序阅读 楼主  发表于: 2011-03-11
— 本帖被 XChinux 从 论坛公告栏 移动到本区(2011-03-11) —
用setcellwidget 添加的button怎么使其居中??谢谢
离线jnblue

只看该作者 1楼 发表于: 2011-03-13
http://stackoverflow.com/questions/3172415/qcombobox-and-qspinbox-in-qtablewidget-with-appropriate-alignment
First, use setCellWidget() to set the QComboBox and QSpinBox as the widgets to be displayed in the appropriate cell.

Second, use horizontalHeader() to access the QHeaderView for the QTableView, then set the ResizeMode accordingly.

QTableWidget* table = new QTableWidget( this ); table->setColumnCount( 2 ); table->setRowCount( 1 ); table->setCellWidget ( 0, 0, new QComboBox( table ) ); table->setCellWidget ( 0, 1, new QSpinBox( table ) ); table->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch ); table->horizontalHeader()->setResizeMode( 1, QHeaderView::ResizeToContents );
快速回复
限100 字节
 
上一个 下一个