• 5911阅读
  • 7回复

请教怎么让QTableView自动占用最大空间呢 [复制链接]

上一主题 下一主题
离线wxyao
 

只看楼主 倒序阅读 楼主  发表于: 2010-09-16
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
请教怎么让QTableView自动占用最大空间呢?

结构如下:
QHBoxLayout *topLayout = new QHBoxLayout;
...
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(topLayout);
mainLayout->addWidget(view);

如附图:

离线beaujolais
只看该作者 1楼 发表于: 2010-09-16
不明白你啥意思~~~

你整个界面只有QTableView么?

如果是的话,this->setLayout(mainLayout);后肯定是占满窗口的~~
离线wxyao

只看该作者 2楼 发表于: 2010-09-16
谢谢关注:-),
        不好意思,我描述的不是很清楚,不只是一个QTableView,上面还有一行横向布局呢。
离线beaujolais
只看该作者 3楼 发表于: 2010-09-16
回 2楼(wxyao) 的帖子
你不会全用代码来布局的吧~~

建议你直接用Designer吧,那样更直观方便些~~
离线wxyao

只看该作者 4楼 发表于: 2010-09-16
还是喜欢全部用代码实现,感觉透明,代码直观些
离线wxyao

只看该作者 5楼 发表于: 2010-09-16
大概找到问题啦,我在那个QWiget外面又套了一层QScrollArea,跟这个有关系。
离线wxyao

只看该作者 6楼 发表于: 2010-09-16
找到原因啦,贴出来,共同学习。

QScrollArea
widgetResizable : bool

This property holds whether the scroll area should resize the view widget.

If this property is set to false (the default), the scroll area honors the size of its widget. Regardless of this property, you can programmatically resize the widget using widget()->resize(), and the scroll area will automatically adjust itself to the new size.

If this property is set to true, the scroll area will automatically resize the widget in order to avoid scroll bars where they can be avoided, or to take advantage of extra space.

Access functions:

bool widgetResizable () const
void setWidgetResizable ( bool resizable )
离线cspp

只看该作者 7楼 发表于: 2010-09-17
用多个布局不久搞定了
上面一个用QHBox,下面一个随便,整个界面用QVBox
快速回复
限100 字节
 
上一个 下一个