Important: Please read the Qt Code of Conduct -

Building a special windows bar

  • Hello,
    can anyone give me an hint how to built an item in QT that is similar to this windows bar in the picture.
    This bar is fixed above the status bar and can be closed. I don't want to have codes. An approximate instruction is ok.


  • Lifetime Qt Champion

    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

    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.

  • Lifetime Qt Champion

    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.

  • Lifetime Qt Champion

    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.

  • Lifetime Qt Champion

    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.

    I know you dont want code but its easier to explain than with words

    class ExtraBar : public QWidget
        QWidget *FixToWidget;
        explicit ExtraBar(QWidget *parent, QWidget *TheFixToWidget);
        ~ExtraBar() override;
        Ui::ExtraBar *ui;
        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
    alt text

    (i painted staturbar red so its easier to see)

    Demo project

    I made the bar with UI file so its easy to fill it out with teh wanted widgets.

  • Thank you very much!!

  • Lifetime Qt Champion

    Np. It just a very fast sample ( 5 mins ) to see if event filter would work as i excepted.
    The bar itself will need some love to look good and be closeable.

Log in to reply