C++&QT 作业8

复制代码
#include "mywind.h"
#include "ui_mywind.h"
#include <iostream>
#include <QIcon>
#include <QLabel>
#include <QLineEdit>
#include <QDebug>//信息调试类  用于输出数据
Mywind::Mywind(QWidget *parent)
    : QWidget(parent)
{
    //qDebug()<<"hello";//使用方式1 类似cout
    //qDebug("%s","good"); //使用方式2 类似printf
    //qDebug()<<QString("%1,%2,%3").arg(10).arg("x").arg("xx");//输出合成的字符串
    qDebug()<<this->size();//获取当前界面的尺寸
    qDebug()<<this->width();//获取当前组件的宽度
    qDebug()<<this->height();//获取当前组件的高度
    this->resize(1000,800); //重新设置尺寸
    //this->resize(QSize(500,400));//使用匿名对象作为函数参数 设置当前组件的尺寸
    //this->setMaximumSize(1000,800);//设置最大尺寸
    //this->setMinimumSize(1000,80);//设置最小尺寸
    this->setFixedSize(1000,800);//设置固定尺寸
    qDebug()<<this->windowTitle();//获取当前组件的窗口标题
    this->setWindowTitle("LOL");//更改窗口标题
    this->setWindowIcon(QIcon("D:\\C++&QT\\qtday1\\zuoye\\lol"));//更改窗口图标
    //this->setStyleSheet("background-color:skyblue;");//改背景色
    //this->setWindowOpacity(0.8);//设置透明度
    // 1 使用无参构造函数  构建一个按钮
    QPushButton *btn1=new QPushButton(QIcon("D:\\C++&QT\\qtday1\\zuoye\\lol"),"登录",this);
    //btn1->show();
    btn1->setParent(this);
    btn1->setText("登录");
    qDebug()<<btn1->size();
    btn1->resize(135,35);
    //qDebug()<<btn1->size();
    //btn1->setQIcon();
    btn1->move(600,700);//移动组件位置
    btn1->setStyleSheet("background-color:skyblue;border-redius:10px;");//设置样式表
    //btn1->setEnabled(false);//设置为不可用状态
    // 2构造一个按钮  构造时直接指定父组件
    QPushButton *btn2=new QPushButton(QIcon("D:\\C++&QT\\qtday1\\zuoye\\lol"),"取消",this);
    btn2->resize(btn1->size());
    btn2->setStyleSheet("background-color:skyblue;border-redius:10px;");
    btn2->move(btn1->x()+200,btn1->y());
//    // 3构造按钮时直接给定文本内容以及父组件
//    QPushButton *btn3=new QPushButton("按钮3",this);
//    btn3->resize(btn1->size());
//    btn3->move(btn1->x(),btn2->y()+50);
    //构造行编辑器对象 并且指定父组件
    QLineEdit *edit1=new QLineEdit(this);
    QLineEdit *edit2=new QLineEdit(this);
    edit1->resize(350,50);
    edit2->resize(350,50);
    edit1->move(600,525);
    edit2->move(600,600);
    edit2->setEchoMode(QLineEdit::Password);//设置回显模式
    edit1->setMaxLength(10);
    edit2->setMaxLength(12);
    edit1->setPlaceholderText("账号");
    edit2->setPlaceholderText("密码");
    //实例化标签  给定初始文本内容 指定父组件
    QLabel *lab1 = new QLabel(this);
    lab1->resize(1000,500);//设置尺寸
    lab1->setPixmap(QPixmap("D:\\C++&QT\\qtday1\\zuoye\\shenwang"));
    lab1->setScaledContents(true); //大小自适应
    QLabel *lab2 = new QLabel(this);
    lab2->setPixmap(QPixmap("D:\\C++&QT\\qtday1\\zuoye\\kazik"));
    lab2->resize(500,300);
    lab2->move(0,500);
    lab2->setScaledContents(true);
    QLabel *lab3 = new QLabel(this);
    lab3->setPixmap(QPixmap("D:\\C++&QT\\qtday1\\zuoye\\denglu"));
    lab3->setScaledContents(true);
    lab3->resize(50,50);
    lab3->move(525,600);
    QLabel *lab4 = new QLabel(this);
    lab4->setPixmap(QPixmap("D:\\C++&QT\\qtday1\\zuoye\\denglu"));
    lab4->setScaledContents(true);
    lab4->resize(50,50);
    lab4->move(525,525);
}

Mywind::~Mywind()
{
}
相关推荐
vx_Biye_Design9 小时前
springboot游泳馆系统93765-计算机课程设计、毕业设计
java·javascript·spring boot·后端·python·spring·课程设计
名字还没想好☜9 小时前
Java NIO ByteBuffer 实战:flip/clear/compact 三个绕晕人的方法与 position/limit 心智模型
java·开发语言·后端·spring·nio
Wang's Blog9 小时前
Java框架快速入门: Spring Security+OAuth2之短信服务多供应商动态切换(阿里云与LeanCloud)
java·spring·阿里云
Doubbbbbbble云9 小时前
区间合并问题的常见算法模式与优化思路4
java·数据结构·算法
小溪学编程9 小时前
AQS 原理详解:从 CLH 队列到 ReentrantLock 的实现
java·开发语言
David猪大卫9 小时前
【C++修炼】哈希表的实现
数据结构·c++·笔记·学习·算法·哈希算法·散列表
广州山泉婚姻10 小时前
列表初始化:C++11全新初始化体系
c++·人工智能
蜗牛互联网10 小时前
语音AI开始边听边说,改变的不只是响应速度
java·人工智能·后端·语音识别
莫生灬灬10 小时前
灵码 LingBuilder:用中文写代码,确定性生成真实 C++ 工程(开源)
c++·开源·mfc
浅念-10 小时前
C++ Protobuf 入门实战:基于通讯录项目吃透proto3语法与序列化
linux·服务器·网络·c++·protobuf·proto·proto3