我有一些连接工具栏。对于我调用的每个工具栏:
toolbar->setGeometry(x,y,width,height)
但我没有调整大小。
我试着打电话
toolbar->updateGeometry();
但什么都没有。
我的目标是用我的尺寸定义扩展每个工具栏
您很有可能使用它在初始化时重新定位工具栏并在关闭时保存。
这是一个可靠的方法:
您真正需要的是使用QMainWindow
saveGeometry()
andrestoreGeometry()
函数并通过 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 );
工具栏的几何图形要么由布局管理,要么由主窗口管理。
您需要展示工具栏是如何使用/显示的。