How to put a layout over a fullscreen item?

  • I want to have a set of buttons "floating" over a full-screen item at the bottom, overlapping it. Can this be done?

  • Moderators

    Edit: sorry, i have seen afterwards that you are looking for a QML solution.

    something like this is a possibility (untested):

    class MyButtonPanel : public QFrame
        MyButtonPanel( QWidget* fullScreenWidget )
            : QFrame( fullScreenWidget, Qt::Window )
               fullScreenWidget->installEventFilter( this );
        virtual bool eventFilter( Qobject* watched, QEvent* event )
               switch( event->type() )
                    case QEvent::Resize:
                    case QEvent::Move:
               return QFrame::eventFilter( watched, event );
    protected slots:
          void updatePosition()
                 if( this->isHidden() )
                 QWidget* fullScreenWidget = this->parentWidget();
                 QRect globalRect = fullScreenWidget->rect();
                      globalRect->moveTopLeft( fullScreenWidget->mapToGlobal( QPoint(0,0) );
                 QRect geometry = this->geometry();
                 geometry.moveBottomRight( globalRect.bottomRight() - QPoint(20,20) );
                 this->setGeometry( geometry );

  • @raven-worx
    Thanks, but I meant QML - this is the Qt Quick section, didn't think I need to specify :)

  • Moderators

    yes, my fault.
    I realized it after i made the post.

  • I think anchors is the way to go. Works like charm:

    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.3
    import ReaderView 1.0
    ApplicationWindow {
        id: window
        CReaderView {
            anchors.fill: parent
            id: readerView
        Button {
            anchors.bottom: readerView.bottom
            anchors.horizontalCenter: readerView.horizontalCenter
            width: 64
            height: 64
            text: "Start"

    I haven't tested with a Layout instead of Button, but hope it'll work.
    Oddly enough, if I anchor to window instead of readerView (which seems more logical because that's what I want to do semantically), it doesn't work right.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.