Chinaunix首页 | 论坛 | 博客
  • 博客访问: 177033
  • 博文数量: 22
  • 博客积分: 1411
  • 博客等级: 上尉
  • 技术积分: 370
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-19 18:12
文章分类
文章存档

2011年(1)

2010年(1)

2008年(20)

我的朋友

分类:

2008-04-22 15:55:16

Adjust QTableWidget to contents & How to set a precise size of QTableWidget to prevent from having scroll bars?
 
I wish to set a precise size which does not leave extra space in the viewport,
and on the other hand, not having scroll bars show up. What is the
precise size?

I wrote an example to demonstrate, Please pay attention to the lines:

this->setVisible(true);
this->setVisible(false);

 

 

 

    autoADCalibrationTableWidget->resizeColumnsToContents();
    auotoADCalibrationTableWidget->resizeRowsToContents();
int newWidth = 0;
    int newHeight =0;
    for (int i = 0; i < autoADCalibrationTableWidget->columnCount(); i++) {
        newWidth+= autoADCalibrationTableWidget->columnWidth(i);
    }
    for (int j = 0; j < autoADCalibrationTableWidget->rowCount(); j++) {
        newHeight+= autoADCalibrationTableWidget->rowHeight(j);
    }

this->setVisible(true);
this->setVisible(false);

    newWidth+=autoADCalibrationTableWidget->verticalHeader()->width() +
2 * autoADCalibrationTableWidget->frameWidth();
    newHeight+=autoADCalibrationTableWidget->horizontalHeader()->height() +
2 * autoADCalibrationTableWidget->frameWidth();

autoADCalibrationTableWidget->setMaximumWidth(newWidth);
autoADCalibrationTableWidget->setMinimumWidth(newWidth);

autoADCalibrationTableWidget->setMaximumHeight(newHeight);
autoADCalibrationTableWidget->setMinimumHeight(newHeight);

阅读(2586) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~