QT1-Hello World

一个基础的QT界面程序

首先需要使用的qt头文件

#include <QtWidgets/qapplication.h>
#include <QtWidgets/qlabel.h>

然后main函数

int main(int argc, char* argv[])
{
	return 0;
}

当我们使用qt的时候

QApplication a(argc, argv);

使用qt的一个类来创建一个a
这个QApplication是什么东西呢?F12进去看看
在这里插入图片描述
QApplication里面定义了不少东西,我们姑且认为它是QT程序的核心或者起始吧


然后我们要输出Hello World的话,必须需要一个载体,这个载体在QT里面使用的是QLable

QLabel label("Hello World");

使用一个class创建一个object,来分析一下QLabel
在这里插入图片描述
我们发现QLabel继承至QFrame。。。
在这里插入图片描述
我们使用的QLabel实际上继承至QObject


label.show();

当我们调用对象的show()方法,就说明我们需要显示这个Label

    virtual void setVisible(bool visible);
    void setHidden(bool hidden);
    void show();
    void hide();

    void showMinimized();
    void showMaximized();
    void showFullScreen();
    void showNormal();

    bool close();
    void raise();
    void lower();

public:
    void stackUnder(QWidget*);
    void move(int x, int y);
    void move(const QPoint &);
    void resize(int w, int h);
    void resize(const QSize &);
    inline void setGeometry(int x, int y, int w, int h);
    void setGeometry(const QRect &);
    QByteArray saveGeometry() const;
    bool restoreGeometry(const QByteArray &geometry);
    void adjustSize();
    bool isVisible() const;
    bool isVisibleTo(const QWidget *) const;
    inline bool isHidden() const;

具体的方法可以有很多

在这里插入图片描述


猜你喜欢

转载自blog.csdn.net/qq_35425243/article/details/82910109
今日推荐