QT day 1

作业:

QT day 1_第1张图片

widget.cpp

#include "window.h"
#include
#include
Window::Window(QWidget *parent)
    : QWidget(parent)
{
    qDebug() <<"size" <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()<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()
{
}

QT day 1_第2张图片

 QT day 1_第3张图片

你可能感兴趣的:(c++)