Building a special windows bar
-
Hi and welcome to the forums
You could use a QFrame with a layout to hold the widgets.
You could just use Designer to make it.To fix it above statusbar, you can override the resize event on MainWindow and place it correctly
when windows is resized.When closing it. You can simply hide() it so its ready to be shown again.
you can use a QPropertyAnimation to make it slide open if you want it a bit fancy :)
(like this menu does https://github.com/chrisaverage/burger-menu/blob/master/src/burgermenu.cpp)Not sure what else to say ?
-
Hello,
thank you for the information. I thought and hoped that QT has build in item for that. I will try to design it with QFrame tomorrow.
Is it possible to put the X(Quit) on the left side? In QT I just now that the quit button is in the top right of a window/widget. -
Hi and welcome to devnet,
The window decoration is not handled at all by Qt. It's the window manager of your OS that manages them.
-
@ppp1
Hi
Your bar would likely be embedded into MainWindow and hence not be a window and therefore have
no default X button but you can make one your self.
There is no such dedicated class but you could use a toolbar or other statusbar if it has features you need but
judging from the image, its just a bunch of widgets in a layout. -
Hi
Instead of using Mainwindows resize event, you could also use an event filter to have it follow the
statusbar and be a more self-contained custom widget.
https://doc.qt.io/qt-5/eventsandfilters.htmlI know you dont want code but its easier to explain than with words
class ExtraBar : public QWidget { Q_OBJECT QWidget *FixToWidget; public: explicit ExtraBar(QWidget *parent, QWidget *TheFixToWidget); ~ExtraBar() override; private: Ui::ExtraBar *ui; protected: bool eventFilter(QObject *obj, QEvent *ev) override { if (!obj->isWidgetType() || !FixToWidget) return false; // the parent is being resized if (ev->type() == QEvent::Resize) { auto g = FixToWidget->geometry(); // take the statusbar location setGeometry(0, g.y() - height() - 2, g.width(), height()); // make us stay on top of it } return false; } };
You can then assign it a parent and a status bar
( in ctor of mainwindow)
auto bar = new ExtraBar(this, ui->statusbar);and it works quite well without anything to be done in MainWinow
(i painted staturbar red so its easier to see)
Demo project
https://www.dropbox.com/s/joah7ume9hcx8e5/ExtraBarTest.zip?dl=0I made the bar with UI file so its easy to fill it out with teh wanted widgets.