QT作业(第一天)

该代码段展示了如何使用Qt库创建一个基本的GUI登录界面,包括设置窗口大小和图标,添加标签、文本输入框和按钮元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    this->resize(1000,800);
    this->setWindowTitle("homework");
    this->setWindowIcon(QIcon("./water.pgn"));
    this->setFixedSize(QSize(300,200));
    this->setWindowOpacity(1);
    QLabel *lab1=new QLabel("logon:",this);
    QLabel *lab2=new QLabel("passwd:",this);

    lab1->resize(50,30);
    lab2->resize(70,30);

    lab1->move(50,50);
    lab2->move(50,100);

    QLineEdit *ledit1=new QLineEdit(this);
    ledit1->resize(150,30);
    QLineEdit *ledit2=new QLineEdit(this);
    ledit2->setEchoMode(QLineEdit::Password);
    ledit2->resize(150,30);
    ledit1->move(125,50);
    ledit2->move(125,100);
    QPushButton *qpush1=new QPushButton(this);
    qpush1->setText("cancel");
    qpush1->resize(70,30);
    qpush1->move(70,150);
    QPushButton *qpush2=new QPushButton(this);
    qpush2->setText("ok");
    qpush2->resize(70,30);
    qpush2->move(170,150);

}

MainWindow::~MainWindow()
{
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值