But did you hide the menu before putting some event processing related code?
This works fine for me:
#include <QtGui>
Q_OBJECT
public:
setText("Take a shot");
connect(this, SIGNAL(clicked()), this, SLOT(makeAShot()));
}
private slots:
void makeAShot(){
hide();
show();
px.save("/tmp/pixmap.jpg");
}
};
#include "main.moc"
int main(int argc, char **argv){
ShotButton button;
button.show();
return app.exec();
}
#include <QtGui>
class ShotButton : public QPushButton {
Q_OBJECT
public:
ShotButton() : QPushButton(){
setText("Take a shot");
connect(this, SIGNAL(clicked()), this, SLOT(makeAShot()));
}
private slots:
void makeAShot(){
hide();
QCoreApplication::sendPostedEvents();
QPixmap px = QPixmap::grabWindow(QApplication::desktop()->winId());
show();
px.save("/tmp/pixmap.jpg");
}
};
#include "main.moc"
int main(int argc, char **argv){
QApplication app(argc, argv);
ShotButton button;
button.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks