qmouseevent

How to use mouseMoveEvent on paintEvent on Qt 5?

感情迁移 提交于 2021-02-13 17:44:19
问题 I'm new on Qt and c++, so I'm having some difficulties. I'm trying to create a widget that can get the mouseMoveEvent position and draw an ellipse on my pixmap on mouse position. Below you can see the code: #include "myimage.h" #include <QPainter> #include <QPen> #include <QColor> #include <QMouseEvent> #include <QDebug> Myimage::Myimage(QWidget *parent) : QWidget(parent) { setMouseTracking(true); // E.g. set in your constructor of your widget. } // Implement in your widget void Myimage:

How to use mouseMoveEvent on paintEvent on Qt 5?

℡╲_俬逩灬. 提交于 2021-02-13 17:39:40
问题 I'm new on Qt and c++, so I'm having some difficulties. I'm trying to create a widget that can get the mouseMoveEvent position and draw an ellipse on my pixmap on mouse position. Below you can see the code: #include "myimage.h" #include <QPainter> #include <QPen> #include <QColor> #include <QMouseEvent> #include <QDebug> Myimage::Myimage(QWidget *parent) : QWidget(parent) { setMouseTracking(true); // E.g. set in your constructor of your widget. } // Implement in your widget void Myimage:

How to use mouseMoveEvent on paintEvent on Qt 5?

时光总嘲笑我的痴心妄想 提交于 2021-02-13 17:38:08
问题 I'm new on Qt and c++, so I'm having some difficulties. I'm trying to create a widget that can get the mouseMoveEvent position and draw an ellipse on my pixmap on mouse position. Below you can see the code: #include "myimage.h" #include <QPainter> #include <QPen> #include <QColor> #include <QMouseEvent> #include <QDebug> Myimage::Myimage(QWidget *parent) : QWidget(parent) { setMouseTracking(true); // E.g. set in your constructor of your widget. } // Implement in your widget void Myimage:

How to move the whole window when mouse is on the window's custom widget in Qt?

眉间皱痕 提交于 2020-08-26 10:02:30
问题 Let's say I have a custom widget and add it to the main window in qt. As you can see, the red area is the custom widget. What I want to do is when the mouse is pressed in the red area and moved, the whole window will move as well. I know how to simply implement mousePressEvent and mouseMoveEvent ; but when dealing with a window with the custom widget, I do not know how to move the whole window when mouse is pressed on the custom widget. Also I want to mention that I only want the window

Qt WebEngine simulate Mouse Event

女生的网名这么多〃 提交于 2020-01-20 09:00:49
问题 I want to simulate mouse Event in my Qt WebEngine app. I use PyQt5.8 , QT5.8 . This is my code: def mouse_click(self, x, y): point = QPoint(int(x), int(y)) eventp = QMouseEvent(QMouseEvent.MouseButtonPress,point,Qt.LeftButton,Qt.LeftButton,Qt.NoModifier) self.sendEvent(eventp) eventp = QMouseEvent(QMouseEvent.MouseButtonRelease,point,Qt.LeftButton,Qt.LeftButton,Qt.NoModifier) self.sendEvent(eventp) def sendEvent(self, event): recipient = self.webpage.view().focusProxy() recipient.grabKeyboard

Qt WebEngine simulate Mouse Event

南楼画角 提交于 2020-01-20 09:00:02
问题 I want to simulate mouse Event in my Qt WebEngine app. I use PyQt5.8 , QT5.8 . This is my code: def mouse_click(self, x, y): point = QPoint(int(x), int(y)) eventp = QMouseEvent(QMouseEvent.MouseButtonPress,point,Qt.LeftButton,Qt.LeftButton,Qt.NoModifier) self.sendEvent(eventp) eventp = QMouseEvent(QMouseEvent.MouseButtonRelease,point,Qt.LeftButton,Qt.LeftButton,Qt.NoModifier) self.sendEvent(eventp) def sendEvent(self, event): recipient = self.webpage.view().focusProxy() recipient.grabKeyboard

PyQt mousePressEvent - get object that was clicked on?

核能气质少年 提交于 2019-12-11 16:17:00
问题 I'm using PyQt and PyQtGraph to build a relatively simple plotting UI. As part of this I have a graphicsview (pyqtgraph's graphicslayoutwidget) that has PlotItems dynamically added to it by the user. What I'm trying to achieve is allowing the user to select a PlotItem by double clicking on it. It's simple enough to get if the user has double clicked somewhere within the widget window, but I can't seem to figure out how to return what was clicked on. Most of my search results have come up with

Qt mouseReleaseEvent() not trigggered?

邮差的信 提交于 2019-12-11 02:07:09
问题 I got a library to display pictures, lets call it PictureGLWidget, with: class PictureGLWidget: public QGLWidget { so PictureGLWidget extends QGLWidget. In PictureGlWidget the void PictureGlWidget::mouseReleaseEvent(QMouseEvent* releaseEvent); is already implemented. I started an own project, lets say class MyMainWindow, where I just use a PictureGlWidget as a Pointerobject: PictureGlWidget * myPictureGLWidget = new PictureGlWidget(...); //.. layout->addWidget(myPictureGLWidget , 0, 1); Here

How to connect to mousePressEvent slot Qt

谁都会走 提交于 2019-12-07 14:32:51
问题 In Class Buttons , I have a btnRightClicked signal and a mousePressEvent slot: void Buttons::mousePressEvent(QMouseEvent *e) { if(e->button() == Qt::RightButton) { emit btnRightClicked(); } } And in mainwindow.cpp , I connect the btnRightClicked signal to onRightClicked slot like this: connect(&mButtons, SIGNAL(btnRightClicked()), this, SLOT(onRightClicked())); The onRightClicked slot is like this: void MainWindow::onRightClicked() { qDebug() << "right clicked"; } But I ran this program,

How to connect to mousePressEvent slot Qt

别等时光非礼了梦想. 提交于 2019-12-06 00:45:50
In Class Buttons , I have a btnRightClicked signal and a mousePressEvent slot: void Buttons::mousePressEvent(QMouseEvent *e) { if(e->button() == Qt::RightButton) { emit btnRightClicked(); } } And in mainwindow.cpp , I connect the btnRightClicked signal to onRightClicked slot like this: connect(&mButtons, SIGNAL(btnRightClicked()), this, SLOT(onRightClicked())); The onRightClicked slot is like this: void MainWindow::onRightClicked() { qDebug() << "right clicked"; } But I ran this program, nothing happened. I guess the reason is because I did not connect to the mousePressEvent slot. I am kind of