Qt 5.10 Book Examples
MainWindow.h
Go to the documentation of this file.
1 // ======================================================================
2 // MainWindow.h
3 // ======================================================================
4 // This file is a part of the book
5 // "Qt 5.10 Professional programming with C++"
6 // http://qt-book.com
7 // ======================================================================
8 // Copyright (c) 2017 by Max Schlee
9 // ======================================================================
10 
11 #pragma once
12 
13 #include <QtWidgets>
14 
15 // ======================================================================
16 class MainWindow : public QMainWindow {
17 Q_OBJECT
18 private:
19  QLabel* m_plblX;
20  QLabel* m_plblY;
21 
22 protected:
23  virtual void mouseMoveEvent(QMouseEvent* pe)
24  {
25  m_plblX->setText("X=" + QString().setNum(pe->x()));
26  m_plblY->setText("Y=" + QString().setNum(pe->y()));
27  }
28 
29 public:
30  MainWindow(QWidget* pwgt = 0) : QMainWindow(pwgt)
31  {
32  setMouseTracking(true);
33 
34  m_plblX = new QLabel(this);
35  m_plblY = new QLabel(this);
36  statusBar()->addWidget(m_plblY);
37  statusBar()->addWidget(m_plblX);
38  }
39 };
MainWindow(QWidget *pwgt=0)
Definition: MainWindow.h:30
virtual void mouseMoveEvent(QMouseEvent *pe)
Definition: MainWindow.h:23