You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mainwidget.cpp 637B

12345678910111213141516171819202122232425262728293031323334
  1. #include "mainwidget.h"
  2. #include "ui_mainwidget.h"
  3. MainWidget::MainWidget(QWidget *parent) :
  4. QDialog(parent),
  5. ui(new Ui::MainWidget),
  6. exitOnLostFocus(false)
  7. {
  8. ui->setupUi(this);
  9. setWindowFlags( Qt::CustomizeWindowHint );
  10. }
  11. MainWidget::~MainWidget()
  12. {
  13. delete ui;
  14. }
  15. void MainWidget::setExitOnLostFocus(bool exit)
  16. {
  17. exitOnLostFocus = exit;
  18. }
  19. bool MainWidget::event(QEvent *e)
  20. {
  21. if (e->type() == QEvent::WindowDeactivate && exitOnLostFocus)
  22. qApp->exit();
  23. return QWidget::event(e);
  24. }
  25. void MainWidget::keyReleaseEvent(QKeyEvent *e)
  26. {
  27. if (e->key() == Qt::Key_Escape)
  28. qApp->exit();
  29. }