MouseEvent breaking through QDeclarativeView and upwards!
-
Hi, all!
I'm working on a implementation of a GUI i designed in Qt.
I wan't to construct a borderless-window and reimplement systembuttons (close,minimize,maximize) and resizing/moving using QML for the titlebar. The problem I'm having is that QMainWindow::mousePressEvent() doesn't fire when the QDecalarativeView is clicked. I will also need mousearea-events later to implement some buttons on the QML itself. But for now I'm only looking to let the c++ backend move the window.
Has anybody got any good ideas where I should look to find a solution?
Thanks all :D!
-
How do you add the QDeclarativeView to the QMainWindow ?
-
I am also facing the same issue.... I would like to move my widget using mouse.. But its not getting the mouse events... Upper layer of my widget will be QML....
this is inside constructor to load QML file...
@view = new QDeclarativeView(this);
view->setSource(QUrl("qml/Button.qml"));
view->setAttribute(Qt::WA_TranslucentBackground);
view->setStyleSheet("background:transparent;");@These are the mouse events which i re-implemented,
@void mousePressEvent(QMouseEvent* event)
{
event->accept(); // do not propagate
if (isWindow())
offset = event->globalPos() - pos();
else
offset = event->pos();
}void mouseMoveEvent(QMouseEvent* event) { event->accept(); // do not propagate if (isWindow()) move(event->globalPos() - offset); else move(mapToParent(event->pos() - offset)); } void mouseReleaseEvent(QMouseEvent* event) { event->accept(); // do not propagate offset = QPoint(); }@
Can anyone suggest a way to implement this...