如何在Qt中的QDockWidget中设置状态栏上的文本并启用关闭按钮?
我里面有一个 QDockWidget 和 QToolBar 。我尝试为 QdockWidget 设置 StatusBar
但无法设置。
每个 QDockWidget 都有默认的关闭按钮(右上角),但我的 DockWidget 没有它?
为什么 ?以及如何把它带回来?
myClass::myClass(QWidget* parent) :
QDockWidget(parent)
{
hide();
QWidget* newWidget = new QWidget();
QBoxLayout* tLayout = new QBoxLayout(QBoxLayout::TopToBottom,newWidget );
tLayout->setContentsMargins(0, 0, 0, 0);
QLabel *label = new QLabel("My Window",this);
this->setTitleBarWidget(label);
tbar = new QToolBar;
tbar->setIconSize(QSize(35,35));
tbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
tLayout->addWidget(tbar,0,Qt::AlignTop);
QGraphicsScene* scene = new QGraphicsScene(this);
QGraphicsView* view = new QGraphicsView(this);
view->setScene(scene);
tLayout->addWidget(view);
newWidget ->setLayout(tLayout);
bar = new QStatusBar();
bar->showMessage(tr("Ready"));
this->setWidget(bar);
setWidget(newWidget);
}
如何设置状态栏?并启用关闭按钮?
I have a QDockWidget and QToolBar in it. I tried to set StatusBar
for QdockWidget but it could not be set.
Every QDockWidget has default close button (top most right corner) but my DockWidget does not have it ?
Why ? And how to bring it back ?
myClass::myClass(QWidget* parent) :
QDockWidget(parent)
{
hide();
QWidget* newWidget = new QWidget();
QBoxLayout* tLayout = new QBoxLayout(QBoxLayout::TopToBottom,newWidget );
tLayout->setContentsMargins(0, 0, 0, 0);
QLabel *label = new QLabel("My Window",this);
this->setTitleBarWidget(label);
tbar = new QToolBar;
tbar->setIconSize(QSize(35,35));
tbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
tLayout->addWidget(tbar,0,Qt::AlignTop);
QGraphicsScene* scene = new QGraphicsScene(this);
QGraphicsView* view = new QGraphicsView(this);
view->setScene(scene);
tLayout->addWidget(view);
newWidget ->setLayout(tLayout);
bar = new QStatusBar();
bar->showMessage(tr("Ready"));
this->setWidget(bar);
setWidget(newWidget);
}
How to set status bar ? and enable close button ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)