Getting toolbar to always stay at the top
-
Hey there,
I have been working on a project and I am having trouble with a QToolBar called navigationBar. I would like the toolbar to stay at the top of the window regardless of if the window is resized. Right now it starts off at the top, but if I resize the window it stays where it is and the rest of the window expands leaving it in the center of the window. How do I get it to always stay at the top?
heres the code:
@hud::hud(QWidget *parent) :
QMainWindow(parent)
{
this->setAttribute( Qt::WA_TranslucentBackground );
//this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
/this->setStyleSheet(
"background-color:rgba(217,85,74,0.1);"
);/quitButton = new QToolButton; quitButton->setText("X"); QToolBar *navigationBar = new QToolBar; navigationBar->addWidget(quitButton); navigationBar->setStyleSheet( "height:20px;" "margin:0px;" ); app1 = new QToolButton; app1->setText("App"); app1->setStyleSheet( "border-style:flat;" "background-color:rgba(255,255,255,1.0);" ); app2 = new QToolButton; app2->setText("App"); app3 = new QToolButton; app3->setText("App"); app4 = new QToolButton; app4->setText("App"); QGridLayout *appsLayout = new QGridLayout; appsLayout->addWidget(app1); appsLayout->addWidget(app2); appsLayout->addWidget(app3); appsLayout->addWidget(app4); QVBoxLayout *masterLayout = new QVBoxLayout; masterLayout->setMargin(0); masterLayout->addWidget(navigationBar); masterLayout->addLayout(appsLayout); setLayout(masterLayout); masterWidget = new QWidget; masterWidget->setStyleSheet( "float:top;" "margin-top:0px;" "margin-bottom:0px;" "background-color:rgba(217,85,74,0.1);" ); masterWidget->setLayout(masterLayout); setCentralWidget(masterWidget);
}
@Thank you!