QT day1 (图形界面设计)
要求:
功能函数模块
#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)
{qDebug("%s","hello world");//qDebug() << "hello world" ;//设置固定尺寸this->setFixedSize(QSize(500,420));qDebug()<<"title : "<<this->windowTitle();//设置窗口名称this->setWindowTitle("QQ");qDebug()<<"title : "<<this->windowTitle();this->setWindowIcon(QIcon("E:/QQdownload/icon_nhgbq8i4bf/QQ.png"));//this->setStyleSheet("background-color:skyblue;");//设置透明度// this->setWindowOpacity(0.8);QLabel *lab3=new QLabel(this);lab3->resize(500,200);lab3->setScaledContents(true);lab3->setPixmap(QPixmap("E:/QQdownload/icon_nhgbq8i4bf/qww.png"));//设置纯净窗口//this->setWindowFlags(Qt::FramelessWindowHint);//按钮类QPushButton//手动定义一个按钮,取名按钮1;QPushButton *bin1 = new QPushButton;//bin1->show();bin1->setParent(this);//重新设置大小bin1->resize(100,30);bin1->setText("登录");bin1->move(180,350);bin1->setStyleSheet("background-color:skyblue;");//2.手动构造一个按钮,并在构造时给定父组件QPushButton *bin2=new QPushButton(this);bin2->resize(bin1->size());bin2->setText("取消");bin2->move(300,350);bin2->setStyleSheet("background-color:skyblue;");QPushButton *bin4 = new QPushButton(QIcon("E:/QQdownload/icon_nhgbq8i4bf/QQ.png"),"注册",this);bin4->resize(bin1->size());bin4->move(10,380);bin4->setStyleSheet("background-color:white;");bin4->setEnabled(false);//5,手动构造行编辑器QLineEdit *edit1 = new QLineEdit(this);edit1->resize(200,35);edit1->move(150,220);edit1->setStyleSheet("background-color:white;");edit1->setPlaceholderText("账号");QLineEdit *edit2 = new QLineEdit(this);edit2->move(150,270);edit2->resize(edit1->size());edit2->setEchoMode(QLineEdit::Password);edit2->setPlaceholderText("密码");edit2->setStyleSheet("background-color:white;");// QLineEdit *edit3 = new QLineEdit("请输入",this);// edit3->move(250,150);// edit3->resize(edit1->size());//清空文本内容edit2->clear();/////7、手动构造一个标签QLabel *lab1=new QLabel("账户:",this);lab1->resize(30,35);lab1->move(100,220);lab1->setScaledContents(true);lab1->setPixmap(QPixmap("E:/QQdownload/icon_nhgbq8i4bf/QQ.png"));QLabel *lab2=new QLabel("密码:",this);lab2->resize(lab1->size());lab2->move(100,270);// lab2->setStyleSheet("background-color:skyblue;");lab2->setScaledContents(true);lab2->setPixmap(QPixmap("E:/QQdownload/icon_nhgbq8i4bf/denglumima.png"));}MainWindow::~MainWindow()
{delete ui;
}
做出如下效果图: