C++简单界面设计

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

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    ---------------------窗口设置----------------------
    this->setWindowTitle("南城贤子摄影工作室");//设置窗口标题
    this->setWindowIcon(QIcon("d:\\Pictures\\Camera Roll\\rr"));//设置窗口图标
    this->setWindowFlag(Qt::FramelessWindowHint);//设置纯净标题
    this->resize(540,415);//设置大小
    this->setStyleSheet("background-color:white");//设置背景颜色

    ---------------------标签设置----------------------
    QLabel *bel1=new QLabel(this);//设置一个标签
    bel1->resize(540,415);//设置大小
    bel1->setStyleSheet("background-color:green");//设置背景颜色
    //实例化一个动图指针
    QMovie *mv=new QMovie("d:\\Pictures\\Camera Roll\\dd");
    bel1->setMovie(mv);//将动图设置到标签中
    mv->start();//动图动起来
    bel1->setScaledContents(true);//自适应大小

    QLabel *bel2=new QLabel(this);
    bel2->resize(30,30);
    bel2->move(125,210);
    bel2->setPixmap(QPixmap("d:\\Pictures\\Camera Roll\\oo"));
    bel2->setScaledContents(true);

    QLabel *bel3=new QLabel(this);
    bel3->resize(30,30);
    bel3->move(125,260);
    bel3->setPixmap(QPixmap("d:\\Pictures\\Camera Roll\\passwd"));
    bel3->setScaledContents(true);

    --------------------行编辑器设置-------------------
    QLineEdit *dit1=new QLineEdit(this);//构造一个行编辑器
    dit1->move(160,210);
    dit1->resize(280,30);
    dit1->setPlaceholderText("QQ号码/手机/邮箱");//设置占位

    QLineEdit *dit2=new QLineEdit(this);//构造一个行编辑器
    dit2->move(160,260);
    dit2->resize(280,30);
    dit2->setPlaceholderText("密码");//设置占位
    dit2->setEchoMode(QLineEdit::Password);

    --------------------按钮设置-------------------
    QPushButton *btn=new QPushButton("登录",this);
    btn->move(125,345);
    btn->resize(300,45);//设置按钮大小
    btn->setStyleSheet("background-color:rgb(8,189,253);border-radius:5px;color:white");//设置背景,按钮样式,字体颜色

}

MyWidget::~MyWidget()
{
}
相关推荐
感哥14 小时前
C++ 多态
c++
沐怡旸21 小时前
【底层机制】std::string 解决的痛点?是什么?怎么实现的?怎么正确用?
c++·面试
River4161 天前
Javer 学 c++(十三):引用篇
c++·后端
感哥1 天前
C++ std::set
c++
侃侃_天下1 天前
最终的信号类
开发语言·c++·算法
博笙困了1 天前
AcWing学习——差分
c++·算法
echoarts1 天前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
Aomnitrix1 天前
知识管理新范式——cpolar+Wiki.js打造企业级分布式知识库
开发语言·javascript·分布式
青草地溪水旁1 天前
设计模式(C++)详解—抽象工厂模式 (Abstract Factory)(2)
c++·设计模式·抽象工厂模式
青草地溪水旁1 天前
设计模式(C++)详解—抽象工厂模式 (Abstract Factory)(1)
c++·设计模式·抽象工厂模式