Will generate mouse press event :
connect(pb, SIGNAL(pressed()()), s_map, SLOT(map()));
Will generate mouse press event :
QPushButton *pb = new QPushButton();
connect(pb, SIGNAL(pressed()()), s_map, SLOT(map()));
QMouseEvent* press = new QMouseEvent(QEvent::MouseButtonPress, pb->rect().center(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::postEvent(pb, press);
To copy to clipboard, switch view to plain text mode
If you want mouse click :
connect(pb, SIGNAL(clicked()()), s_map, SLOT(map()));
QPushButton *pb = new QPushButton();
connect(pb, SIGNAL(clicked()()), s_map, SLOT(map()));
QMouseEvent* press = new QMouseEvent(QEvent::MouseButtonPress, pb->rect().center(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QMouseEvent* release = new QMouseEvent(QEvent::MouseButtonRelease, pb->rect().center(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::postEvent(pb, press);
QApplication::postEvent(pb, release);
To copy to clipboard, switch view to plain text mode
you can refer QMouseEvent for more info
Bookmarks