简单Qt界面应用与开发

widget.h

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QIcon>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
};
#endif // WIDGET_H

main.cpp

#include "widget.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
    return a.exec();
}

widget.cpp

​
#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->setFixedSize(550,450);
    this->setWindowTitle("QQ");
    this->setWindowIcon(QIcon("D:\\C++ Qt pro\\icon_z8w8m9orsdk\\QQ.png"));
//    this->setStyleSheet("background-color:skyblue;");

    QLabel *lab1 = new QLabel(this);
    QLabel *lab2 = new QLabel(this);
    QLabel *lab3 = new QLabel(this);
    lab1->resize(550,158);
//    lab1->setStyleSheet("background-color:pink;");
    lab1->setPixmap(QPixmap("D:\\C++ Qt pro\\icon_z8w8m9orsdk\\R-C.jpg"));
    lab1->setScaledContents(true);

    lab2->resize(40,30);
    lab2->move(150,200);
//    lab2->setStyleSheet("background-color:pink;");
    lab2->setPixmap(QPixmap("D:\\C++ Qt pro\\icon_z8w8m9orsdk\\denglu.png"));
    lab2->setScaledContents(true);
    lab3->resize(lab2->size());
    lab3->move(150,260);
//    lab3->setStyleSheet("background-color:pink;");
    lab3->setPixmap(QPixmap("D:\\C++ Qt pro\\icon_z8w8m9orsdk\\denglumima.png"));
    lab3->setScaledContents(true);

    QLineEdit *edit1 = new  QLineEdit(this);
    QLineEdit *edit2 = new  QLineEdit(this);
    edit1->resize(210,30);
    edit1->move(190,200);
    edit1->setPlaceholderText("QQ账号/手机号/邮箱");
    edit2->resize(edit1->size());
    edit2->move(190,260);
    edit2->setPlaceholderText("密码");
    edit2->setEchoMode(QLineEdit::Password);

    QPushButton  *btn1 = new QPushButton(QIcon("D:\\C++ Qt pro\\icon_z8w8m9orsdk\\denglu_1.png"),"登录",this);
    QPushButton  *btn2 = new QPushButton(QIcon("D:\\C++ Qt pro\\icon_z8w8m9orsdk\\quxiao.png"),"取消",this);
    btn1->resize(100,50);
    btn1->move(200,330);
    btn1->setStyleSheet("background-color:skyblue;");
    btn2->resize(btn1->size());
    btn2->move(350,330);

}

Widget::~Widget()
{
}


​

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值