• C++&QT 作业8


     

    1. #include "mywind.h"
    2. #include "ui_mywind.h"
    3. #include <iostream>
    4. #include <QIcon>
    5. #include <QLabel>
    6. #include <QLineEdit>
    7. #include <QDebug>//信息调试类 用于输出数据
    8. Mywind::Mywind(QWidget *parent)
    9. : QWidget(parent)
    10. {
    11. //qDebug()<<"hello";//使用方式1 类似cout
    12. //qDebug("%s","good"); //使用方式2 类似printf
    13. //qDebug()<<QString("%1,%2,%3").arg(10).arg("x").arg("xx");//输出合成的字符串
    14. qDebug()<<this->size();//获取当前界面的尺寸
    15. qDebug()<<this->width();//获取当前组件的宽度
    16. qDebug()<<this->height();//获取当前组件的高度
    17. this->resize(1000,800); //重新设置尺寸
    18. //this->resize(QSize(500,400));//使用匿名对象作为函数参数 设置当前组件的尺寸
    19. //this->setMaximumSize(1000,800);//设置最大尺寸
    20. //this->setMinimumSize(1000,80);//设置最小尺寸
    21. this->setFixedSize(1000,800);//设置固定尺寸
    22. qDebug()<<this->windowTitle();//获取当前组件的窗口标题
    23. this->setWindowTitle("LOL");//更改窗口标题
    24. this->setWindowIcon(QIcon("D:\\C++&QT\\qtday1\\zuoye\\lol"));//更改窗口图标
    25. //this->setStyleSheet("background-color:skyblue;");//改背景色
    26. //this->setWindowOpacity(0.8);//设置透明度
    27. // 1 使用无参构造函数 构建一个按钮
    28. QLabel *lab2 = new QLabel(this);
    29. lab2->setPixmap(QPixmap("D:\\C++&QT\\qtday1\\kazik"));
    30. lab2->resize(1000,600);
    31. lab2->move(0,300);
    32. lab2->setScaledContents(true);
    33. QPushButton *btn1=new QPushButton(QIcon("D:\\C++&QT\\qtday1\\zuoye\\lol"),"登录",this);
    34. //btn1->show();
    35. btn1->setParent(this);
    36. btn1->setText("登录");
    37. qDebug()<<btn1->size();
    38. btn1->resize(135,35);
    39. //qDebug()<<btn1->size();
    40. //btn1->setQIcon();
    41. btn1->move(600,700);//移动组件位置
    42. btn1->setStyleSheet("background-color:skyblue;border-redius:10px;");//设置样式表
    43. //btn1->setEnabled(false);//设置为不可用状态
    44. // 2构造一个按钮 构造时直接指定父组件
    45. QPushButton *btn2=new QPushButton(QIcon("D:\\C++&QT\\qtday1\\zuoye\\lol"),"取消",this);
    46. btn2->resize(btn1->size());
    47. btn2->setStyleSheet("background-color:skyblue;border-redius:10px;");
    48. btn2->move(btn1->x()+200,btn1->y());
    49. // // 3构造按钮时直接给定文本内容以及父组件
    50. // QPushButton *btn3=new QPushButton("按钮3",this);
    51. // btn3->resize(btn1->size());
    52. // btn3->move(btn1->x(),btn2->y()+50);
    53. //构造行编辑器对象 并且指定父组件
    54. QLineEdit *edit1=new QLineEdit(this);
    55. QLineEdit *edit2=new QLineEdit(this);
    56. edit1->resize(350,50);
    57. edit2->resize(350,50);
    58. edit1->move(600,525);
    59. edit2->move(600,600);
    60. edit2->setEchoMode(QLineEdit::Password);//设置回显模式
    61. edit1->setMaxLength(10);
    62. edit2->setMaxLength(12);
    63. edit1->setPlaceholderText("账号");
    64. edit2->setPlaceholderText("密码");
    65. //实例化标签 给定初始文本内容 指定父组件
    66. QLabel *lab1 = new QLabel(this);
    67. lab1->resize(1000,400);//设置尺寸
    68. lab1->setPixmap(QPixmap("D:\\C++&QT\\qtday1\\zuoye\\shenwang"));
    69. lab1->setScaledContents(true); //大小自适应
    70. QLabel *lab3 = new QLabel(this);
    71. lab3->setPixmap(QPixmap("D:\\C++&QT\\qtday1\\zuoye\\denglu"));
    72. lab3->setScaledContents(true);
    73. lab3->resize(50,50);
    74. lab3->move(525,600);
    75. QLabel *lab4 = new QLabel(this);
    76. lab4->setPixmap(QPixmap("D:\\C++&QT\\qtday1\\zuoye\\denglu"));
    77. lab4->setScaledContents(true);
    78. lab4->resize(50,50);
    79. lab4->move(525,525);
    80. }
    81. Mywind::~Mywind()
    82. {
    83. }

  • 相关阅读:
    uview组件使用笔记
    成功解决NotImplementedError: cannot instantiate ‘WindowsPath‘ on your system
    76页智慧物流园区综合解决方案2022(附下载)
    一篇文章带你入门HBase
    JavaScript的DOM技术
    70.qt quick-QQmlListProperty详解
    Docker网络功能
    EasyExcel对大数据量表格操作导入导出
    45.C++中的异常处理
    《CTF特训营》——古典密码学
  • 原文地址:https://blog.csdn.net/weixin_55993382/article/details/132911346