Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MouseEvent breaking through QDeclarativeView and upwards!
Forum Updated to NodeBB v4.3 + New Features

MouseEvent breaking through QDeclarativeView and upwards!

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    acidr
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luca
      wrote on last edited by
      #2

      How do you add the QDeclarativeView to the QMainWindow ?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mammamia
        wrote on last edited by
        #3

        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...

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved