QMouseEvent on button click
-
@uruloke
you have to addprotected:
void mousePressEvent(QMouseEvent *eventPress);to mainwindow .H
and
void mousePressEvent(QMouseEvent *eventPress) {
}
in .cppits a virtual function and must be named like this.
It will then be called by system.
What you seems to try is to put MouseEvent *eventPress to a button click.
and it will be zero as it not filled out by system since a buttons click is not the same as mouse click.
so you sort of give it a empty QMouseEvent.Note its protected: that is important.
-
-
@mrjj
Ah, yeah I forgot that it was an event :)void mousePressEvent(QMouseEvent *eventPress) { QPoint p = mapFromGlobal(eventPress->globalPos()); ui->pixMap->setText( QString::number(p.x()) + "," + QString::number(p.x())); }
I get errors on
mapFromGlobal
now andui
, didn't get that before. -
@uruloke
ahh. such beast. :)
make sure to borrow from
http://doc.qt.io/qt-5/qtwidgets-desktop-screenshot-example.html