I have a custom implementation of QChartView where I can zoom. (Class "ChartView" from this example)
In there I have a mousePressEvent.
Now I wanted to add a QScatterSeries and connect the clicked signal with a custom slot. Unfortunately as soon as I click on my QScatterSeries only a signal is emitted to my ChartView mousePressEvent slot and not to my QScatterSeries mypoint_clicked slot.
I also added an QScatterSeries hovered signal which works fine.
connect(myScatterSeries, SIGNAL(hovered(QPointF,bool)), this, SLOT(mypoint_hovered(QPointF,bool)));
connect(myScatterSeries, SIGNAL(clicked(QPointF)), this, SLOT(mypoint_clicked(QPointF)));
Just guessing here.
mousePressEvent() is not a slot, but an event handler. I guess that QChartView::mousePressEvent() is somewhat responsible for handling mouse press events on the chart and dispatching them to series.
If you reimplemented ChartView::mousePressEvent() without explicitly calling QChartView::mousePressEvent() to forward the event, you might prevent the normal event processing to dispatch the event to the series. And therefore QScatterSeries::clicked() is never emitted.
Related
How can I catch a mouse hold event in either Qt or Qt Modeling Language? I don't mean hold as in press the button and wait a certain delay before emitting a signal. I mean a user clicks a button and while its not released I want it to emit signals so that I can, for example make an object follow the mouse position while its being held down.
The way i solved it was using a Timer event. Each time the Timer was triggered, id check if the mouse was pressed.
There is a "entered" signal for a QTreeView Widget, which I can use to check if my mouse moves over an item.
Is there a way to implement an "left" signal?
Why:
I have a treeView with a lot of items which I also plot via QChart. I want to highlight the plot when someone mouse over the data in the treeview.
I can highlight it via the "entered" signal, but I have no idea how to change it back to the default if the mouse left/mouse is over another item...
entered is a member of QAbstractItemView. You should probably reimplement QAbstractItemView::dragLeaveEvent virtual method.
See this method documentation: http://doc.qt.io/qt-5/qabstractitemview.html#dragLeaveEvent
I have a slider:
QSlider *mySlider;
And I have a slot wired to it:
void on_mySlider_sliderMoved(int position);
It's wired in setupUI when this is called:
QMetaObject::connectSlotsByName(MainWindow);
When I slide the slider with the mouse, this slot fires correctly and all is well. However, if I click it once with the mouse to "select" it and then use the arrows on the keyboard, I see the slider moving, but the slot never fires.
What am I doing wrong?
QAbstractSlider::sliderMoved signal is emitted when you drag the slider. From the docs: This signal is emitted when sliderDown is true and the slider moves. This usually happens when the user is dragging the slider.
Use QAbstractSlider::valueChanged signal if you want to know every time the value of the slider is changed.
Which SIGNAL is emitted, when pressing the "X" in the top right corner of a Qt Window application?
I have a second QDialog widget beside my MainWindow in my Qt application. And I would like to intercept the press on the "X" in my second QDialog, how?
The QCloseEvent class contains parameters that describe a close event. Close events are sent to widgets that the user wants to close, usually by choosing "Close" from the window menu, or by clicking the X title bar button. They are also sent when you call QWidget::close() to close a widget programmatically.
To ignore it you can call ignore() method:
void YourDialog::closeEvent(QCloseEvent* iEvent)
{
// ignore close event
iEvent->ignore();
}
There is no signal for that, you need to reimplement QWidget::closeEvent() or install an event filter filtering for QCloseEvents.
I have some problem with handle QML event on touch notebook, events onPressed, onPressAndHold not work, no debug message. I trying event handle through Qt class, but i have failure (connect QML and Qt using QDeclarativeView).
How i can write global event handler whitch register QML touch event on noutbook.
Thanks.
You can use an event filter from C++. E.g. if you reimplement QApplication::notify in a QApplication subclass you should be able to hook into anything. Might be useful to check that your App works on other (mouse-based) platforms. QML's MouseArea uses Mouse Events and not touch. If your platform only uses touch events, and doesn't fake mouse events - you might need to look at the gesturearea research QML plugin; http://qt.gitorious.org/qt-labs/qml-gesturearea