QT Day1

课后作业:1)完成对头文件初始函数的注释

2)完成聊天室UI的创建

示例:QT Day1_第1张图片

1)

QT Day1_第2张图片

2)

QT Day1_第3张图片

#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    //设置窗口名称
    this->setWindowTitle("CenZywush聊天室");
    //设置窗口图标
    this->setWindowIcon(QIcon("C:\\Users\\CenZywush\\Desktop\\2.png"));
    //设置窗口大小
    this->setFixedSize(550,460);
    //定义图片1
    QLabel *label1=new QLabel(this);
    //自适应设置的大小
    label1->setScaledContents(true);
    label1->resize(550,200);
    QPixmap a("C:\\Users\\CenZywush\\Desktop\\icon\\icon\\6.png");
    label1->setPixmap(a);

    QLabel *label2=new QLabel(this);
    label2->setScaledContents(true);
    label2->resize(40,40);
    label2->move(120,230);
    QPixmap b("C:\\Users\\CenZywush\\Desktop\\icon\\icon\\userName.jpg");
    label2->setPixmap(b);

    QLabel *label3=new QLabel(this);
    label3->setScaledContents(true);
    label3->resize(40,40);
    label3->move(120,320);
    QPixmap c("C:\\Users\\CenZywush\\Desktop\\icon\\icon\\passwd.jpg");
    label3->setPixmap(c);
    //定义按钮
    QPushButton *btn1 = new QPushButton(this);
    btn1->setText("登录");
    btn1->resize(QSize(100,45));
    btn1->move(280,400);
    //btn1->setEnabled(false);
    btn1->setIcon(QIcon("C:\\Users\\CenZywush\\Desktop\\icon\\icon\\login.png"));

    QPushButton *btn2 = new QPushButton(this);
    btn2->setText("取消");
    btn2->resize(QSize(100,45));
    btn2->move(390,400);
    //btn2->setEnabled(false);
    btn2->setIcon(QIcon("C:\\Users\\CenZywush\\Desktop\\icon\\icon\\cancel.png"));

    QLineEdit *lineEdit1 = new QLineEdit(this);
    lineEdit1->setPlaceholderText("QQ号码/手机/邮箱");
    lineEdit1->setMaxLength(100);
    lineEdit1->setGeometry(220, 230, 220, 50);
    QFont font1;
    font1.setPointSize(15);
    lineEdit1->setFont(font1);

    QLineEdit *lineEdit2 = new QLineEdit(this);
    lineEdit2->setPlaceholderText("密码");
    lineEdit2->setMaxLength(100);
    lineEdit2->setGeometry(220, 320, 220, 50);
    QFont font2;
    font2.setPointSize(15);
    lineEdit2->setFont(font2);
    lineEdit2->setEchoMode(QLineEdit::Password);
}
Widget::~Widget()
{
}

思维导图:

QT Day1_第4张图片

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