Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. X and Y mouse position
Forum Updated to NodeBB v4.3 + New Features

X and Y mouse position

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 290 Views
  • 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
    Alby
    wrote on last edited by
    #1

    Hi, i have a problem,

    I need x and y mouse position, bat this code doesn't work:


    void MainWindow::mousePressEvent(QMouseEvent *event)
    {
    if(event->button() == Qt::RightButton)
    {
    pan_x = event->x();
    pan_y = event->y();
    }
    }


    Practically, i have a function ''mousePressEvent" with 'QMouseEvent *event' parameter, the function controll if the event is a right click mouse, in that case, it should, set 'pan_x' to value of x mouse position and 'pan_y' to value of y mouse position.

    In any case, it generates these error:
    error.png

    Other information:

    • I use 6.1.2 version of QT
    • I have already included: '<QMouseEvent>'
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I don't see errors, just deprecation warnings. And there is also a hint on how to fix them.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Alby
        wrote on last edited by
        #3

        You are right, it isn't error, sorry me;
        But how do i resolve this deprecation warnings, I don't understand anything from the suggestions? (I'm new to Qt)

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The error message says it's all - use QMouseEvent::position() instead.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          3
          • A Offline
            A Offline
            Alby
            wrote on last edited by
            #5

            Ok thank you

            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