Questions tagged [qmouseevent]

The QMouseEvent class contains parameters that describe a mouse event.

The QMouseEvent class contains parameters that describe a mouse event.

Mouse events occur when a mouse button is pressed or released inside a widget, or when the mouse cursor is moved.

Mouse move events will occur only when a mouse button is pressed down, unless mouse tracking has been enabled with QWidget::setMouseTracking().

Qt automatically grabs the mouse when a mouse button is pressed inside a widget; the widget will continue to receive mouse events until the last mouse button is released.

A mouse event contains a special accept flag that indicates whether the receiver wants the event. You should call ignore() if the mouse event is not handled by your widget. A mouse event is propagated up the parent widget chain until a widget accepts it with accept(), or an event filter consumes it.

Note: If a mouse event is propagated to a widget for which Qt::WA_NoMousePropagation has been set, that mouse event will not be propagated further up the parent widget chain.

The state of the keyboard modifier keys can be found by calling the modifiers() function, inherited from QInputEvent.

The functions pos(), x(), and y() give the cursor position relative to the widget that receives the mouse event. If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.

The QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.

Reimplement the QWidget event handlers, QWidget::mousePressEvent(), QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(), and QWidget::mouseMoveEvent() to receive mouse events in your own widgets.

Reference: http://qt-project.org/doc/qt-4.8/qmouseevent.html

90 questions
2
votes
1 answer

How to receive mouse events in QGraphicsItem derived class? Qt

There are already threads about this, but the solution I could find does not work. Solution: writing QGraphicsView::MousePressEvent(event); at the end of my MousePressEvent class in the QGraphicsView derived class. Both do not work. The…
mep
  • 341
  • 2
  • 11
2
votes
0 answers

Qt check if mouse in bounding rect of QGraphicsItem

I want to drag GQraphicsPixmapItem by clicking on any point inside bounding rect of the pixmap. The problem is if the pixmap has transparent parts (png images), then the item does not receive mouse events unless mouse is on top of actual…
Zheden
  • 583
  • 2
  • 11
  • 36
2
votes
0 answers

QToolTip::showText disappears after mouse relese

Inside a mousePressEvent I do QToolTip::showText(evt->globalPos(), "Test", this, rect(), 1000); But the tooltip disappears after releasing the mouse button. If I don't release it, the tooltip disappears after that 1000 msecs.
iBent
  • 392
  • 1
  • 2
  • 18
2
votes
2 answers

Qt : catched mouseMoseEvent dont interact with QWebView html page element

I catch the mouseMoveEvent of my QWebView for restarting a timer of a screensaver. The problem is that now the mouseMoveEvent isnt distribued to the HTML elements so its impossible for example to move a sliding bar on the page. I use connect to bind…
Robin
  • 129
  • 9
2
votes
0 answers

QDrag::exec is not calling QGraphicsView mouseRelease

i have implemented the mousePress, mouseMove and mouseRelase in the QGraphicsView and i have added a QGraphicsWidget and a QGraphicsLayoutItem in it and added to the view. now inside the graphicsLayoutitem i have implemented void…
Wagmare
  • 1,354
  • 1
  • 24
  • 58
1
vote
0 answers

Can not select qcombobox item with touch

I develop Qt Application with a touchscreen. I use a combobox to display a list of computer comports. It works fine with mouse event, when I want to select an item from the combobox. When I use touch event, the combobox pops up the dropdown scroll,…
1
vote
1 answer

get mouse position in the QGraphicScene with pixels coordinate

i try to create a program to manipulate images,I want to have the position of the mouse when it is in the Qgraphicscene, but the event of the mouse is not triggered unless I start outside the Qgraphicview, how can i get this position with the…
Ay Men
  • 90
  • 7
1
vote
1 answer

Zoom in / Zoom out in QT without using scroll button

I want to zoom in/out a part in openGL using mouse. Now I can do it well using the scroll button in mouse. But my goal is now to perform the same operation by holding the left mouse button and moving the mouse to and fro in the screen. I don't know…
aadhithyan
  • 49
  • 10
1
vote
2 answers

re-send an event to a newly enabled child widget

NOTE: below is in edit with a more complete example I want to implement the following in Qt (specifically PyQt, but I believe that the solution will be similar in both python and C++): I want a widget to have an internal widget that is disabled by…
bentheiii
  • 451
  • 3
  • 15
1
vote
1 answer

How to constrain a QRubberBand within a QLabel?

I am building a Qt5 application that allows a user to draw a rubberband with his mouse over an image, to select certain area of the image for further processing. I got my code to only allow the user to start drawing the rubberband, by subclassing a…
LemuelKL
  • 11
  • 6
1
vote
1 answer

MouseMove event on cell in Qtablewidget to display or print a message

I have QTablewidget and I want to use a mousemoveevent on a particular cell B. When mouse moves over this cell B, a message would appear or be printed. I have created the constructor, but it really does not work. Every thing is allright expect from…
Pavel.D
  • 561
  • 1
  • 15
  • 41
1
vote
0 answers

How to get global coordinate of the mouse outside of the application in Qt?

I build a new element which is inherited from QWidget and is a combination of a LineEdit and a Button. Now when I click into the button, a list should be shown (or in another word, a completer should be shown). Now the requirement is, when I…
songvan
  • 369
  • 5
  • 21
1
vote
1 answer

PySide2 pass mouse events to system

I'm using a QDialog with transparency enabled to select a region of the screen for a screen capture tool. When the user clicks inside the transparent widget I want to ignore the mouse event so that the system handles it. Is this possible? I'm trying…
Green Cell
  • 4,677
  • 2
  • 18
  • 49
1
vote
0 answers

Why I can´t perform a left mouse click?

I am creating a software that moves the mouse cursor and performs left and right clicks. I got the cursor moving but I can´t perform left clicks. What am I doing wrong? let point = CGPoint(x:366, y:528) // Random point self.moveCursor(point:…
Spk
  • 11
  • 1
1
vote
1 answer

Is there any better way to move a window?

I am working on an application with Qt Framework for desktop. Since I remove every window decoration I had to implement the main window to receive move event from when the user click on it and move the mouse around. I tried the following code but I…
user9191494