A signal slot
Similar windows message mechanism, but unlike the windows as the need to accept the message of the specified object.
Function signal, the receiver transmits only need to know.
Slot function, regardless of who receives just sent.
To bind by QObject.
Principle: binding signal functions and slot function, when the calling signal is essentially a function of the signal written in the queue, the main thread to obtain signals from the queue. Note that many internal slot function can not be called in external thread.
QApplication a(argv,argc);
a.exec (); // loop through the main thread.
The method of addition signal slots
The first
The second
Adding a third channel signal, manual
All the added signal of the slot function class must add a Q_OBJECT described. QT moc use by the program determines whether there Q_OBJECT control whether generated code automatically.
Create a manual signal signals, just declare without definition.
Manually create grooves public slots, you need to be defined.
/ * Caller object address signal, a signal, receives an address, the slot function * /
QObject::connect(ui.tests, SIGNAL(clicked()), this, SLOT(testSlot()));
QObject::disconnect(ui.tests, SIGNAL(clicked()), this, SLOT(testSlot()));
QObject::connect(&x, SIGNAL(move(int, int, int)), &w, SLOT(Move(int, int)));
Note that the parameter signal must be greater than the slot function parameters.
The definition of a signal
signals:
void ViewSig();
A groove defined function
public slots:
void ViewSlot();
Two, QWidget description
QWidget class is the base class for all user interface objects, the window member receiving mouse and keyboard events; QWidget simultaneously draws itself on the screen. QWidget parent-child object has relative coordinates.
QWidget create objects manually
QWidget w;
w.show (); // child window comprises a display, it is noted that show () function is a groove.
w.hide (); // hide the window
The coordinates and size of the window QWidget
To obtain or set the coordinates and size QRect geometry (); setGeometry (x, y, width, height);
To the specified coordinates and to resize: move, resize
Be sure to call attention to get the coordinates in w.show () after.
Window Type
// When removing the biggest title bar Minimize button, etc., into a borderless mode, Qt5.9 when doing 3D development, borderless mode will be blocked at issue
this->setWindowFlags(Qt::FramelessWindowHint);
// remove the minimize button maximize
this->setWindowFlag(Qt::WindowMinimizeButtonHint, false);
this->setWindowFlag(Qt::WindowMaximizeButtonHint, false);
// retained the title bar, remove all the buttons this-> setWindowFlags (Qt :: WindowTitleHint | Qt :: CustomizeWindowHint);
// Only the close button
this->setWindowFlags(Qt::WindowCloseButtonHint);