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
0
votes
1 answer

try to use QMouseEvent

I've a problem with QMouseEvent: void Gioco::gioco_G1() { QMouseEvent *mouse = new QMouseEvent; bool stato = false; do { if (mouse->KeyPress() == Qt::MouseButton::LeftButton) { qDebug()<<"entra nell'if"; if (img_mano1G1 ->…
0
votes
2 answers

Qt C++ QLabel Clickable mouse events doesn't work

I have a big doubt and problem. After try a lot of tutorials and examples, I cannot receive signal clicks in my QLabel. If I do the same, but in a QDialog (not in a QLabel), I can know the status of the mouse. I paste my example code, before that, I…
Diego
  • 35
  • 7
0
votes
1 answer

QHeaderView mouse tracking fails

I need to connect some simple filter functionality, to a mouse click on a QTreeView header item. Simple enough, I implemented a slot function that connects to: QTreeView::header()->sectionClicked(int) After setting…
Basti Vagabond
  • 1,458
  • 1
  • 18
  • 26
0
votes
1 answer

QTextEdit focusOut programmatically doesn't work

I have a custom QTextEdit which overrides ::mouseMoveEvent(QMouseEvent *e) and ::focusOutEvent(QFocusEvent *e). The context of QTextEdit is selectable. In selection mode, when the user exceeds QTextEdit's bounds I want to stop the selection…
Ispas Claudiu
  • 1,890
  • 2
  • 28
  • 54
0
votes
1 answer

How can I know if a QGraphicsItem created in a separate class has moved on a scene (changed it's position)?

I've created a GraphicsItem in a new class and have sent it to the GraphicsView in another file. I've set the flag ItemIsMovable as true and I am able to move the item. How can I know where the user has moved it to? And, how can I then set the…
Alarming
  • 137
  • 1
  • 3
  • 14
0
votes
2 answers

Filtering Mouse clicks in Qt within a class

I want to be able to enable and disable filtering mouse clicks on my entire QMainWindow by pressing a button or a key which will cause filtering to start. I want to enable the event filter from inside a class, QMainWindow. I want to be able to have…
johnramsden
  • 291
  • 5
  • 14
0
votes
0 answers

python3.4 + pyqt5: Getting x,y out of QMouseEvent

python3.4+pyqt5 I'm trying to write a program in which buttons shall create other buttons by dragging and press_releasing to form a representation of a rolling mill street. I created a class Button which does the moving and handles several clicking…
camaro
  • 118
  • 12
0
votes
2 answers

Using QDialog inside MousePressEvent

I have a class, that subclasses QDialog without overriding exec(), accept() or reject() and another one, that calls the Dialog class inside its mousePaintEvent: void Canvas::mousePressEvent(QMouseEvent *event) { if (event->button() ==…
Ivan Bratoev
  • 235
  • 2
  • 13
0
votes
1 answer

QPainter black trace when moving QWidget

I created a small test application with 2 widgets, one inside the other. I reimplemented the mouse move, press and release events for the inner widget in order to be able to move it inside its bigger parent with drag&drop. However, when I move it a…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
0
votes
0 answers

QGraphicsItemGroup after removall not able to add new

I am attaching scene_ on QGraphicsView QGraphicsItem* scene_ = new QGraphicsScene(this); setScene(scene_); on scene I am adding 2 things QGraphicsItem* prev_pixmap_item_ = scene_->addPixmap(pm); scene_->addItem(prev_pixmap_item_); …
0
votes
2 answers

Determine mouse event: hover leave parent for child widget

I have 2 widgets, a parent and a child widget: Having access to the implementation of the red widget, is it possible to determine the moment when the cursor hovers out of the red widget into the blue widget without implementing any event handlers…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
0
votes
0 answers

QMenu is not displaying but still able to interact with it

I have a graphic manager that is used to manage and interact with graphics using mouse input. Inside the mousePressEvent (not overidden from QWidget, is just a normal method that gets passed mouse location and buttons from a QWidget) I create a…
Will-of-fortune
  • 167
  • 1
  • 3
  • 16
0
votes
1 answer

On mouseleave of one div AND mouseenter of other div when both condition true

There is 4 divs like following
hello
hi
KpBhat
  • 29
  • 7
0
votes
1 answer

Multiple file insert in QTreewidget using Drag and Drop events

I am working in Qt4.7 on MAC OSx. I want to insert files in QTreewidget using the Drag and Drop events. I want to add multiple files at a time. I am using this: void MainWindow::dragEnterEvent(QDragEnterEvent * e) { …
Ashish
  • 219
  • 2
  • 6
  • 22
-1
votes
1 answer

QT MouseMove Simulation in QWidget not working

I am trying to grab touch events from one widget and simulate it in another widget.The grab and simulate touch events are working fine for mousePressEvent,mouseReleaseEvent.But when I try to simulate mouseMoveEvent the corresponding events are not…
prasanth
  • 19
  • 4
1 2 3 4 5
6