我正在使用 qt 开发嵌入式图形用户界面应用程序。我正在使用 2 个 QStatusBars 制作一个可以在示波器上看到的类似菜单的按钮:
我的问题是我不知道以一定宽度将按钮彼此分开的正确方法。在图片中,您可以看到我添加了几个分隔符来实现这一点,但在目标上运行时看起来并不是那样。
有没有更好的方法将 QStatusBar 上的按钮分隔成一定宽度?
最佳答案
我希望您使用空白小部件按照 Martin 的建议进行分离,就像这样;
//the 2 widgets in the status bar
button1 = new QPushButton("Button1");
button2 = new QPushButton("Button2");
//the blank widget. You can set your width with 'setFixedWidth(int)'
widget = new QWidget;
widget->setFixedWidth(50);
widget->setHidden(1);
widget->setVisible(1);
//placing them in the status bar
statusBar = new QStatusBar;
statusBar->addWidget(button1);
statusBar->addWidget(widget);
statusBar->addWidget(button2);
关于c++ - Qt QStatusBar 更宽的分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30348476/