Unsolved 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?
-
Edit: sorry, i have seen afterwards that you are looking for a QML solution.
@Violet-Giraffe
something like this is a possibility (untested):class MyButtonPanel : public QFrame { public: 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: this->updatePosition(); break; return QFrame::eventFilter( watched, event ); } protected slots: void updatePosition() { if( this->isHidden() ) return; 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 :) -
@Violet-Giraffe
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 ofButton
, but hope it'll work.
Oddly enough, if I anchor towindow
instead ofreaderView
(which seems more logical because that's what I want to do semantically), it doesn't work right.