9.28 Qt界面

cpp 复制代码
#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->setWindowTitle("Plane");
    this->setWindowIcon(QIcon("C:/Users/EDY/Desktop/递送发送.png"));
    QPushButton *btn1=new QPushButton;

    this->setFixedSize(640,480);
    btn1->setParent(this);   //将界面设置为父组件
    btn1->setText("登录");    //设置按钮文本
    btn1->move(200,350);
    btn1->resize(120,40);
    btn1->setStyleSheet("color:white;background-color:skyblue;border-radius:10px;"); //设置按钮样式表

    QPushButton *btn2=new QPushButton(this);
    btn2->setText("取消");
    btn2->move(btn1->x()+btn1->width()+20,btn1->y());
    btn2->resize(btn1->size());
    btn2->setStyleSheet("background-color:white;border-radius:10px;");

    QLineEdit *acc =new QLineEdit(this);
    acc->resize(260,30);
    acc->move(200,250);
    acc->setAlignment(Qt::AlignCenter);  //文本居中显示
    acc->setEchoMode(QLineEdit::Normal); //设置文本显示模式
    acc->setPlaceholderText("请输入账号"); //设置占位文本

    QLineEdit *pwd =new QLineEdit(this);
    pwd->resize(acc->size());
    pwd->move(acc->x(),acc->y()+acc->height()+20);
    pwd->setEchoMode(QLineEdit::Password);
    pwd->setPlaceholderText("请输入密码");
    pwd->setAlignment(Qt::AlignCenter);

    QLabel *logo=new QLabel;
    logo->setParent(this);
    logo->resize(150,150);
    logo->setPixmap(QPixmap("C:/Users/EDY/Desktop/递送发送.png"));  //插入图片显示
    logo->setScaledContents(true);  //图片填充
    logo->move(250,60);
}

Widget::~Widget()
{
}
相关推荐
molaifeng3 分钟前
从 utf8.RuneCountInString 看 Go 是如何高性能、安全地解码 UTF-8 的
开发语言·安全·golang
小此方4 分钟前
Re: ゼロから学ぶ C++ 入門(七)类和对象·第四篇:拷贝构造函数&赋值运算符重载
开发语言·c++
月明长歌6 分钟前
【码道初阶】【LeetCode387】如何高效找到字符串中第一个不重复的字符?
java·开发语言·数据结构·算法·leetcode·哈希算法
杨了个杨89827 分钟前
PostgreSQL主从复制部署
数据库
l1t8 分钟前
wsl docker安装达梦数据库的过程
数据库·docker·容器·达梦
凯子坚持 c8 分钟前
Protobuf 序列化协议深度技术白皮书与 C++ 开发全流程指南
开发语言·c++
superman超哥8 分钟前
仓颉Union类型的定义与应用深度解析
开发语言·后端·python·c#·仓颉
智航GIS9 分钟前
1.1 Python的前世今生
开发语言·python
superman超哥9 分钟前
仓颉协变与逆变的应用场景深度解析
c语言·开发语言·c++·python·仓颉
Filotimo_9 分钟前
在java后端开发中,kafka的用处
java·开发语言