【发布时间】:2014-04-14 23:58:07
【问题描述】:
我有一些连接工具栏。对于我调用的每个工具栏:
toolbar->setGeometry(x,y,width,height)
但我没有调整大小。
我试着打电话
toolbar->updateGeometry();
但什么都没有。
我的目标是用我的尺寸定义扩展每个工具栏
【问题讨论】:
-
什么是尺寸策略类型?
我有一些连接工具栏。对于我调用的每个工具栏:
toolbar->setGeometry(x,y,width,height)
但我没有调整大小。
我试着打电话
toolbar->updateGeometry();
但什么都没有。
我的目标是用我的尺寸定义扩展每个工具栏
【问题讨论】:
您很有可能使用它在初始化时重新定位工具栏并在关闭时保存。
这是一个可靠的方法:
你真正需要的是使用QMainWindowsaveGeometry()和restoreGeometry()函数,通过QSettings接口保存和加载字节数组。
写入设置
QSettings s;
s.beginGroup("MainWindow");
this->restoreGeometry(s.value("geometry").toByteArray());
this->restoreState(s.value("windowState").toByteArray());
s.endGroup();
读取设置
QSettings s;
s.beginGroup("MainWindow");
s.setValue("geometry", saveGeometry());
s.setValue("windowState", saveState());
s.endGroup();
希望对您有所帮助。
【讨论】:
您可以尝试QWidget::resize( int w, int h ) 调整工具栏的大小。
toolbar-> resize( 200, 20 );
【讨论】:
工具栏的几何图形要么由布局管理,要么由主窗口管理。
您需要展示工具栏是如何使用/显示的。
【讨论】: