How to disable the mouse press event while user can drag any item for QwebView without mousepressevent() function. because i am not promote a QWebView class .
Related
In a Qt 5.7 application, QActions on a QToolbar only call their _triggered() slot/callback when the mouse is pressed and released while over that toolbar icon.
How do I configure QAction so that the _triggered() event occurs as soon as the mousedown event occurs over the icon, without waiting for mouse-up?
In QWindow there is a signal windowStateChanged(Qt::WindowState).
I'm looking for similar signal in QMainWindow. Is it available?
I need it to notify toolbar about fullscreen change, as I have a checkable toolbar button which changes window to fullscreen when user clicks it. However when user changes to fullscreen bypassing the button, it shows invalid state.
QMainWindow inherits from QWidget where you find the ::setWindowState(Qt::WindowStates) method. In its docs, it says:
When the window state changes, the widget receives a changeEvent() of type QEvent::WindowStateChange.
So it seems like you have to override changeEvent() to handle this, I don't think there is a signal.
I have my custom widget inherited from QWidget, and I've connected the widget's menu-calling signal to my slot.
connect(m_ontologyView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showContextMenuSlot(QPoint)));
Now I want user to be able to change button calling the context menu. Normally it's called with right mouse button, but how do I tell the widget to call the menu with a button of my choice?
I'm on Qt 5.4.0
Instead of using QWidget::customContextMenuRequested, you will need to reimplement the widgets mouse event functions, QWidget::mousePressEvent, QWidget::mouseReleaseEvent and QWidget::mouseMoveEvent. Inside of these events, you can then show you menu using QMenu::popup. (The point can be extracted from the mouse events).
I am using a QMainWindow with few QLineEdits and with some QPushButtons in it. When the focus is in a QLineEdit (if I type something in the QLineEdit) and if I press the F5 key, I want to show a QDialog.
That QDialog contains a QTableView. My question is, when I press the F5 key, I want to move the focus from the QLineEdit to the QTableView's cell. How can I achieve this?
Subclass QLineEdit and override keyPressEvent() to detect when the F5 key is pressed, or install an event filter on the QLineEdit.
If you create and show the dialog during the key event processing the dialog will automatically receive a focus in event and the first widget in the dialog that accepts focus will be the widget in focus. So either let the QTableView be the first widget, or explicitly give the focus to it using setFocus().
If the dialog is already constructed or is a non-modal dialog which is already open, you need a pointer to the dialog so that you can show it/give it the focus when the F5 key is pressed.
If you want to move to a certain cell in the QTableView you of course also need to know the cell associated with your QLineEdit.
I have a simple parent widget that reimplements mousePressEvent/mouseReleaseEvent. The parent's child widgets use enterEvent/leaveEvent. When I hover the mouse over the child widgets, leaveEvent/enterEvent executes, but when I click and hold the mouse, mousePressEvent executes, but enterEvent/leaveEvent goes silent (in other words, no click and drag). Any ideas about what could be causing this?
If you press and hold down the mouse button on a widget then that widget grabs mouse events until you release the button. This is not a special feature of Qt, you can find similar behaviour in every other GUI APIs I know.
Take a look at the relevant part of the Qt documentation:
QWidget / Events:
mousePressEvent() is called when a mouse button is pressed while the
mouse cursor is inside the widget, or when the widget has grabbed the
mouse using grabMouse(). Pressing the mouse without releasing it is
effectively the same as calling grabMouse().
void QWidget::grabMouse ():
Grabs the mouse input. This widget receives all mouse events until
releaseMouse() is called; other widgets get no mouse events at all.