[英]How to set QToolButton fill in the side bar(QDockWidget) in Qt?
[英]How to set text on status bar and enabled close button in QDockWidget in Qt?
我有一個 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);
}
如何設置狀態欄? 並啟用關閉按鈕?
// change to:
QWidget* newWidget = new QWidget(this);
...
tbar = new QToolBar(this);
...
bar = new QStatusBar(this);
// replace:
this->setWidget(bar);
// with:
tLayout->addWidget(bar);
// replace:
this->setTitleBarWidget(label);
// with:
titleBarWidget()->layout()->insertItem(0, label);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.