【问题标题】:QT - Resize QToolbarQT - 调整 QToolbar 的大小
【发布时间】:2014-04-14 23:58:07
【问题描述】:

我有一些连接工具栏。对于我调用的每个工具栏:

toolbar->setGeometry(x,y,width,height)

但我没有调整大小。

我试着打电话

toolbar->updateGeometry();

但什么都没有。

我的目标是用我的尺寸定义扩展每个工具栏

【问题讨论】:

  • 什么是尺寸策略类型?

标签: qt size qtoolbar


【解决方案1】:

您很有可能使用它在初始化时重新定位工具栏并在关闭时保存。

这是一个可靠的方法:

你真正需要的是使用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();

希望对您有所帮助。

【讨论】:

    【解决方案2】:

    您可以尝试QWidget::resize( int w, int h ) 调整工具栏的大小。

    toolbar-> resize( 200, 20 );
    

    【讨论】:

    • 我非常想知道如何工具栏停靠。尤其是在使用触摸屏时,它会非常好。
    【解决方案3】:

    工具栏的几何图形要么由布局管理,要么由主窗口管理。

    您需要展示工具栏是如何使用/显示的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多