Qt C ++ development

There are three base classes for window classes: QWidget, QMainWindow, QDialog, and QWidget is used by default.
QPushButton: Button control, used when there is no UI designer page, generally defined as a pointer variable. Since the original type in Qt does not support copy constructor, it can only be used through a pointer; in addition. It is also convenient to use signal and slot mechanisms.
Object tree: When creating an object in Qt, you need to provide a QObject type parent object pointer, so that the parent object will add this QObject object to the children list, when the parent object is destructed, all field items will also be destructed , But note that the relationship here is not a parent-child relationship of inheritance.
Object tree: When the created object is in the heap area, if the specified parent object is a QObject derived class, you do not need to manage the release operation of the object.
Object tree: To a certain extent, Qt simplifies the memory recycling mechanism; however, the objects on the delete stack will cause memory errors; in addition, the child object does not know whether it is deleted, and wild pointers may appear.
The coordinate system of Qt: the upper left corner is 0,0 points, x to the right is the positive direction, and y is the positive direction.
Custom signal:
    signals: // Write in signals tag
        void fun (int a); // Return value void, just declare, no need to implement; can have parameters, support overloading
Custom slots:
    public slots: // early In the Qt version, it can only be written in public slots, the advanced version can be written to public or global
        void handle (int a); // can have a return value (signal and slot are decoupled solutions, it is not recommended to have a return value) ; Can have parameters, support heavy-duty
signal and slot connection: connect (1,2,3,4)
    1: Signal sender
    2: Signal sent (function address-function pointer)
    3: Signal receiver
    4: Signal processor (slot function address-function pointer)
QString to char *: qs.ToUtf8 () to QBytyArray; .Data () is converted to char *.
Disconnect: disconnect (1,2,3,4); // The parameters are consistent with connect.


 

Published 31 original articles · Like1 · Visits1160

Guess you like

Origin blog.csdn.net/quietbxj/article/details/105371322