- #ifndef MYCK_H
- #define MYCK_H
-
- #include
-
- QT_BEGIN_NAMESPACE
- namespace Ui { class myck; }
- QT_END_NAMESPACE
-
- class myck : public QWidget
- {
- Q_OBJECT
-
- public:
- myck(QWidget *parent = nullptr);
- ~myck();
-
- private:
- Ui::myck *ui;
- };
- #endif // MYCK_H
- #include "myck.h"
- #include "ui_myck.h"
- #include<iostream>
- #include<QDebug>
- #include<QPushButton>
- #include<QLineEdit>
- #include<QLabel>
-
-
- myck::myck(QWidget *parent)
- : QWidget(parent)
- , ui(new Ui::myck)
- {
- ui->setupUi(this);
-
-
- qDebug() << this->size(); //获取当前界面的尺寸
- this->setWindowTitle("原神"); //设置窗口标题
- this->setWindowIcon(QIcon("C:\\Users\\Administrator\\Desktop\\ys.png")); //设置窗口图标
-
- //1、设置按钮1
- QPushButton *btn1 = new QPushButton; //无参构造一个按钮
- btn1->setParent(this); //将当前界面设置父组件
- btn1->setText("原神启动"); //定义按钮内容
- btn1->resize(100,50); //设置按钮大小
- btn1->move(240,470); //移动按钮位置
- btn1->setIcon(QIcon("C:\\Users\\Administrator\\Desktop\\ys.png")); //设置按钮图标
-
-
-
- //2、设置第按钮2
- QPushButton *btn2 = new QPushButton(this);
- btn2->setText("取消启动");
- btn2->resize(100,50);
- btn2->move(500,470);
-
-
- //3、构造一个行编辑器,并指定父组件
- QLineEdit *edit1 = new QLineEdit(this);
- edit1->resize(400,50); //设置行编辑器大小
- edit1->move(240,320); //移动行编辑器
- edit1->setPlaceholderText("输入手机号/邮箱"); //设置占位文本
-
-
-
- QLineEdit *edit2 = new QLineEdit(this); //设置第二个行编辑器
- edit2->setPlaceholderText("输入密码");
- edit2->setEchoMode(QLineEdit::Password); //设置回显
- edit2->resize(400,50);
- edit2->move(240,380);
-
-
- //4、设置标签
- QLabel *lab1 = new QLabel(this);
- lab1->resize(800,300);
- lab1->setPixmap(QPixmap("C:\\Users\\Administrator\\Desktop\\ys4.png"));
- lab1->setScaledContents(true);
-
- QLabel *lab2 = new QLabel(this);
- lab2->resize(120,50);
- lab2->setPixmap(QPixmap("C:\\Users\\Administrator\\Desktop\\ys5.png"));
- lab2->move(120,320);
- lab2->setScaledContents(true);
-
-
- }
-
- myck::~myck()
- {
- delete ui;
- }
- #include "myck.h"
-
- #include
-
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- myck w;
- w.show();
- return a.exec();
- }
效果图