QT day 1

作业:

widget.cpp

#include "window.h"
#include<QDebug>
#include<QIcon>
Window::Window(QWidget *parent)
    : QWidget(parent)
{
    qDebug() <<"size" <<this->size();
    //
    this->resize(430,330);
    this->resize(QSize(800,600));
    //  this->setMaximumSize(430,330);
     //  this->setMinimumSize(430,330);
    this->setFixedSize(430,330);
    qDebug()<< this->windowTitle();
    this->setWindowTitle("WeChat");
    this->setWindowIcon(QIcon("E:\\c\\qt1\\111.png"));
    this->setStyleSheet("background-color:skyblue;");
    this->setWindowOpacity(1);
    //无参构造
    QPushButton *bt1 =new QPushButton;
    //给组件指定父组件,让其依附于界面
    bt1->setParent(this);
    //设置组件文本内容
    bt1->setText("开始");
    qDebug()<<bt1->size();
    this->setFixedSize(430,330);
    //设置按钮组件的大小
    bt1->resize(QSize(50,30));
   //移动组件位置
    bt1->move(200,290);
    //设置样式表
    bt1->setStyleSheet("background-color:red");
    bt1->setIcon(QIcon("E:\\c\\qt1\\111.png"));
    //2.构造一个按钮
    QPushButton *bt2 = new QPushButton(this);
    bt2->setText("取消");
    bt2->resize(bt1->size());
    bt2->move(300,290);
   // bt2->setStyleSheet("background-color:blue");
   // bt2->setEnabled(false);
    bt2->setIcon(QIcon("E:\\c\\qt1\\111.png"));
    //3.
     QLabel *bt3 =new QLabel(this);
    bt3->resize(bt1->size());
    bt3->move(100,170);
    bt3->setPixmap(QString("E:\\c\\qt1\\111.png"));
    //设置 内容自适应
    bt3->setScaledContents(true);
    //4.
    QLabel *bt4 =new QLabel(this);
    bt4->resize(bt1->size());
    bt4->move(100,220);
    bt4->setPixmap(QString("E:\\c\\qt1\\222.png"));
    //设置 内容自适应
    bt4->setScaledContents(true);
    /***********************************/
    QLineEdit *ed1 =new QLineEdit(this);
    //ed1->setText(""); //设置编辑器中的文本
    //设置占位文本
    ed1->setPlaceholderText("密码:");
    //设置尺寸
    ed1->resize(180,30);
    //移动位置
    ed1->move(bt4->x()+60,bt4->y());
    ed1->setPlaceholderText("密码:");
    ed1->setEchoMode(QLineEdit::Password);
    //2.构造一个行编辑器,构造时给定父,以及文本内容
    QLineEdit *ed2 = new QLineEdit(this);
    ed2->resize(180,30);
    ed2->move(bt3->x()+60,bt3->y());
    ed2->setPlaceholderText("账号 /手机 /邮箱...");
     /***********************************/
    QLabel *la1 =new QLabel(this);
    la1 ->resize(430,140);
    la1->setPixmap(QString("E:\\c\\qt1\\222.png"));
    //设置 内容自适应
    la1->setScaledContents(true);
}
Window::~Window()
{
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zycyydssss

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值