Qt
基本模型与排列组合
编程与搭积木异乎?
展开
-
Qt学习 第37节:QString
在阅读QString文档时,出了一个词implicit sharing(copy-on-write),不是很懂,下面链接解释的表明白QT的隐式共享(Implicit Sharing)_道路与梦想-CSDN博客_qbytearray 隐式共享为了最大化使用系统资源,更少的内存拷贝,QT中的很多类使用了隐式数据共享。当传递参数时,使用隐式共享类既安全又高效,因为只传递对象指针。当对象中的数据被修改时,对象才会被拷贝。也就是我们常说的“写拷贝”(copy-on-write)。概述: ...原创 2022-01-11 14:42:36 · 217 阅读 · 0 评论 -
Qt学习 第37节:QChar
为什么输出是falseqDebug()<<QChar::isNumber(4);boolQChar::isNumber(char32_tucs4)ucs4又是什么?字符编码(ucs2 ucs4 utf)_和尚的专栏-CSDN博客_ucs2和ucs4原创 2022-01-11 02:44:55 · 228 阅读 · 0 评论 -
Qt数据类型
qint8:signed char有符号8比特数据qint16:signed short16位数据类型qint32:signed int32位有符号数据类型qint64:long long int 或(__int64)64位有符号数据类型,Windows中定义为__int64qintptr:qint32 或 qint64指针类型 根据系统类型不同而不同,32位系统为qint32、64位系统为qint64qlonglong: long long int 或(__int64)Wi原创 2022-01-10 23:41:02 · 170 阅读 · 0 评论 -
Qt学习 第36节:QMessageBox
void about(QWidget *parent, const QString &title, const QString &text)//(父类指针,窗口标题,提示文本)void aboutQt(QWidget *parent, const QString &title = QString())//(父类指针,窗口标题)QMessageBox::StandardButton critical(QWidget *parent, const QString &...原创 2022-01-07 20:44:20 · 1129 阅读 · 0 评论 -
Qt学习 第35节:模态对话框和非模态对话框
对话框分为两种:1.模态对话框:应用程序没有关闭前,程序不能向下运行,直到该对话框关闭,调用方式exec()QDialog dlg(this);dlg.exec();//模态对话框,exec()阻塞,程序不会往下执行2.非模态对话框:当被打开时,程序继续往下运行,调用方式show()//使用动态创建,不会自动释放,设置setAttribute为点击关闭后删除QDialog* dlg= new QDialog(this);dlg->setAttribute(Qt::WA_Del原创 2022-01-07 19:29:45 · 386 阅读 · 0 评论 -
Qt学习 第34节:信号槽是怎么工作的
先复习官方文档Signals & Slots | Qt 4.8https://doc.qt.io/archives/qt-4.8/signalsandslots.html原创 2022-01-05 22:49:12 · 250 阅读 · 0 评论 -
Qt学习 第33节:Qt5新语法.信号调用普通函数
#include <QApplication>#include <QPushButton>#include <QDebug>static void someFunction() { qDebug() << "pressed";}int main(int argc, char *argv[]){ QApplication a(argc, argv); QPushButton* button = new QPush...原创 2022-01-05 21:20:30 · 391 阅读 · 0 评论 -
Qt学习 第32节:数字时钟
DigitalClock.h#ifndef DIGITALCLOCK_H#define DIGITALCLOCK_H#include <QLCDNumber>class DigitalClock : public QLCDNumber{ Q_OBJECTpublic: DigitalClock(QWidget *parent = nullptr);private slots: void showTime();};#endif // WID...原创 2022-01-05 16:20:04 · 686 阅读 · 0 评论 -
Qt学习 第31节:信号和槽出现函数重载
Student.h#ifndef STUDENT_H#define STUDENT_H#include <QObject>class Student : public QObject{ Q_OBJECTpublic: explicit Student(QObject *parent = nullptr);signals:public slots: void treat(); void treat(QString food);}...原创 2022-01-04 16:30:56 · 417 阅读 · 0 评论 -
Qt学习 第30节:自定义带参数的信号和槽函数
Student.h#ifndef STUDENT_H#define STUDENT_H#include <QObject>class Student : public QObject{ Q_OBJECTpublic: explicit Student(QObject *parent = nullptr);signals:public slots: void treat(); void treat(QString food);};#e原创 2022-01-04 16:13:04 · 648 阅读 · 0 评论 -
Qt学习 第29节:自定义信号和槽函数
第一个程序Student.h#ifndef STUDENT_H#define STUDENT_H#include <QObject>class Student : public QObject{ Q_OBJECTpublic: explicit Student(QObject *parent = nullptr);signals:public slots: void treat();};#endif // STUDENT_HT原创 2022-01-04 15:38:39 · 71 阅读 · 0 评论 -
Qt学习 第28节:QT对象树
QT在构造对象的时,先构造子类,再完成基类构造,子类构造的顺序,按照代码的顺序构造,析构时,先析构一个对象下的所有子类,再析构基类MyButton.h#ifndef MYBUTTON_H#define MYBUTTON_H#include <QPushButton>class MyButton : public QPushButton{ Q_OBJECTpublic: explicit MyButton(const QString &tex...原创 2022-01-04 15:23:58 · 120 阅读 · 0 评论 -
Qt学习 第27节:Qt静态编译过程
Qt5.11.2 & VS2017 & 64位版本静态编译及使用_YeeZo的博客-CSDN博客_qt 静态编译使用VS2017静态编译Qt程序小伙伴们有没有遇到过,自己使用Qt库开发的小程序,在本地电脑上跑得很欢快,但是当想要把编译好的.exe可执行文件发给朋友玩玩的时候,发现在没有安装Qt或者VS环境的电脑上是跑不了的。究其原因,这是因为大家在编译程序时,使用的是动态编译。也就是说,编译好的程序在运行时还需要另外加上相应的DLL库文件,否则就会出错。而如果想将生成的程序连同所需要的依赖库原创 2022-01-03 20:31:49 · 473 阅读 · 0 评论 -
Qt学习 第26节:Qt编译过程
18:30:49: Running steps for project qt-tutorial-01...1.使用qmake生成qt-tutorial-01.pro项目文件18:30:49: Starting: "C:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\qmake.exe" C:\Users\MarX\Desktop\qt-tutorial-01\qt-tutorial-01.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=原创 2022-01-03 19:11:14 · 2568 阅读 · 0 评论 -
Qt学习 第25节:自定义信号槽
#ifndef WINDOW_H#define WINDOW_H#include <QWidget>class QPushButton;class Window : public QWidget{ Q_OBJECTpublic: explicit Window(QWidget *parent = nullptr);signals: void counterReached();public slots: void slotButtonCl.原创 2022-01-03 14:49:58 · 112 阅读 · 0 评论 -
点乘和叉乘的区别是什么?
假如 向量a 为(x1, y1),向量b为(x2, y2)点积(也叫内积)结果 为 x1 * x2 + y1 * y2 = |a||b| cos<a,b>,可以理解为向量a在向量b上投影的长度乘以向量b的长度。叉积(也叫外积)的模为 x1 * y2 - x2 * y1 = |a||b| sin<a,b>,可以理解为平行四边形的有向面积(三维以上为体积)。外积的方向垂直于这两个方向。作者:信徒链接:https://www.zhihu.com/question/21080171原创 2022-01-02 13:25:06 · 10415 阅读 · 0 评论 -
常见的MIME类型
常见的MIME类型 超文本标记语言文本 .html,.html text/html 普通文本 .txt text/plain RTF文本 .rtf application/rtf GIF图形 .gif image/gif JPEG图形 .jpeg,.jpg image/jpeg au声音文件 .au audio/basic MIDI音乐文件 mid,.midi audio/midi,audio/x-midi RealAudio音乐文件 .ra, .ram audio/x-pn原创 2022-01-01 17:11:22 · 1208 阅读 · 0 评论 -
Qt学习 第24节: QPainter
QPainter can operate on any object that inherits the QPaintDevice class.The common use of QPainter is inside a widget's paint event: Construct and customize (e.g. set the pen or the brush) the painter. Then draw. Remember to destroy the QPainter object a原创 2021-12-29 05:33:14 · 108 阅读 · 0 评论 -
Qt学习 第23节:QPen 和 QBrush
Constant Value Description Qt::white 3 White (#ffffff) Qt::black 2 Black (#000000) Qt::red 7 Red (#ff0000) Qt::darkRed 13 Dark red (#800000) Qt::green 8 Green (#00ff00) Qt::darkGreen 14 Dark green (#008原创 2021-12-28 10:06:07 · 928 阅读 · 0 评论 -
Qt学习 第22节:Qcolor 中的Alpha不透明度
QColor::QColor(int r, int g, int b, int a = ...)Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a.color对象里头的alpha其实是指不透明度,其值范围为0-255,越大越不透明。其通常对应opacity,这个就是单词语义表达的不透明度,其值范围[0,1.0f],值越大,越不透明。opacity与a...原创 2021-12-28 09:54:32 · 3216 阅读 · 0 评论 -
Qt学习 第21节:窗口初始化EVENT
1.WindowTitleChange 改变标题2.Move 窗口位置改变(默认0,0)3.WindowIconChange 改变图标4.Resize 窗口大小改变(默认0)5.show 窗口显示过程消息6.CursorChange 鼠标外形处理7.ShowToParent 显示到父窗口中8.UpdateRequest 通知将要进行窗口的绘制9.WindowActive 获取鼠标焦点10.Paint 绘制窗口外观#i...原创 2021-12-27 07:38:29 · 2187 阅读 · 0 评论 -
Qt学习 第20节:setStyleSheet
#include <QApplication>#include <QSlider>#include <QSpinBox>#include <QVBoxLayout>#include <QLabel>int main(int argc, char *argv[]){ QApplication app(argc, argv); QWidget *window = new QWidget; window-...原创 2021-12-26 14:01:47 · 912 阅读 · 0 评论 -
Qt总结 第1节:QLabel用法
设置位置ui->label->setGeometry(x,y,width,height);//左上角坐标(x,y)label宽高(width,height)设置label字体QFont font("Microsoft YaHei",10,75);//字体,大小,加粗(权重)ui->label->setFont(font)显示图片QPixmap *pixmap = new QPixmap(":/images/welcome_tlauto.png");/原创 2021-12-26 13:43:43 · 1420 阅读 · 0 评论 -
Qt学习 第19节:pro文件
QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++11 release//生成release版本CONFIG -= debug//不生成debug版本目标文件TARGET = app指定程序存放目录DESTDIR = $$PWD/../bin //$$PWD代表当前目录编译宏开关DEFINES += yourdefinesOBJ路径OBJECTS_DIR = $$PWD.原创 2021-12-25 19:14:57 · 387 阅读 · 0 评论 -
Qt学习 第18节:对话框
dialog.h#ifndef DIALOG_H#define DIALOG_H#include <QDialog>namespace Ui {class Dialog;}class Dialog : public QDialog{ Q_OBJECTpublic: explicit Dialog(QWidget *parent = nullptr); ~Dialog();private: Ui::Dialog *ui;...原创 2021-12-25 15:15:31 · 242 阅读 · 0 评论 -
Qt学习 第17节:对话框
对话框分为两种:1.模态对话框:应用程序没有关闭前,用户不能与同一个应用程序的其他窗口进行交互,直到该对话框关闭,exec()2.非模态对话框:当被打开时,用户既可以选择和对话框进行交互,也可以选择同应用程序的其他窗口交互.show()...原创 2021-12-25 10:54:51 · 411 阅读 · 0 评论 -
Qt学习 第17节:调用一个子对话框
dialog.h#ifndef DIALOG_H#define DIALOG_H#include <QDialog>namespace Ui {class Dialog;}class Dialog : public QDialog{ Q_OBJECTpublic: explicit Dialog(QWidget *parent = nullptr); ~Dialog();private: Ui::Dialog *ui;...原创 2021-12-25 10:46:10 · 445 阅读 · 0 评论 -
Qt学习 第16节:图片轮播
#ifndef PICTURE_H#define PICTURE_H#include <QWidget>#include <QLabel>#include <QPixmap>#include <QTimer>#include <QString>class Picture : public QWidget{ Q_OBJECTpublic: Picture(QWidget *parent = nullptr);.原创 2021-12-24 06:37:44 · 509 阅读 · 0 评论 -
Qt学习 第15节:QTimer倒计时
#ifndef WIDGET_H#define WIDGET_H#include <QWidget>#include <QTimer>#include <QLabel>QT_BEGIN_NAMESPACEnamespace Ui { class Widget; }QT_END_NAMESPACEclass Widget : public QWidget{ Q_OBJECTpublic: Widget(QWidget *pare.原创 2021-12-23 15:35:39 · 959 阅读 · 0 评论 -
Qt学习 第14节:搜索窗口
FindDialog.pro####################################################################### Automatically generated by qmake (3.1) Wed Dec 22 19:24:23 2021######################################################################QT += core guiQT += ...原创 2021-12-23 05:33:02 · 793 阅读 · 0 评论 -
Qt学习 第13节:学生成绩查询系统
ui_StudentDialog.h/********************************************************************************** Form generated from reading UI file 'StudentDialog.ui'**** Created by: Qt User Interface Compiler version 5.12.8**** WARNING! All changes made in原创 2021-12-16 06:50:17 · 754 阅读 · 0 评论 -
Qt学习 第12节:更完善的注册界面
/********************************************************************************** Form generated from reading UI file 'LoginDialog.ui'**** Created by: Qt User Interface Compiler version 5.4.1**** WARNING! All changes made in this file will be ...原创 2021-12-15 13:24:17 · 196 阅读 · 0 评论 -
Qt学习 第11节:计算器重构实现
通过Qt designer设计师重构计算器案例使用uic将CalculatorDialog.ui(xml)转换为ui_CalculatorDialog.h(C++)uic .\CalculatorDialog.ui -o .\ui_CalculatorDialog.h注:如果不手动进行转换,将来在Makefile中也可以自动完成使用"ui_CalculatorDialog.h"里面已经自动生成的界面相关的代码,完成代码编写方法一:通过继承方式,将界面相关代码继承过来直接使用方法二:通过...原创 2021-12-14 04:39:46 · 418 阅读 · 0 评论 -
Qt学习 第10节:获取系统时间
#ifndef TIME_H#define TIME_H#include <QWidget>#include <QLabel>#include <QPushButton>#include <QVBoxLayout>#include <QString>#include <QTime>class Time : public QWidget{ Q_OBJECTpublic: Time(QW...原创 2021-12-14 01:35:03 · 915 阅读 · 0 评论 -
Qt学习 第9节:计算器实现
#ifndef CALCULATORDIALOG_H#define CALCULATORDIALOG_H#include <QDialog>#include <QLineEdit>#include <QLabel>#include <QPushButton>#include <QDoubleValidator>//验证器#include <QHBoxLayout>//水平布局其class CalculatorDia.原创 2021-12-13 23:41:57 · 598 阅读 · 0 评论 -
Qt学习 第8节: 注册框
#include <QApplication>#include <QWidget>#include <QLineEdit>#include <QVBoxLayout>#include <QFormLayout>int main(int argc, char *argv[]){ QApplication app(argc, argv); QWidget* window = new QWidget; windo.原创 2021-12-13 09:26:34 · 617 阅读 · 0 评论 -
Qt学习 第7节:模仿QT写代码
#ifndef UI_Window#define UI_Window#include <QtCore/QVariant>#include <QtWidgets/QAction>#include <QtWidgets/QApplication>#include <QtWidgets/QButtonGroup>#include <QtWidgets/QHeaderView>#include <QtWidgets/QMainWin.原创 2021-12-11 23:44:42 · 265 阅读 · 0 评论 -
Qt学习 第6节:使用UI文件
#ifndef USERWINDOW_H#define USERWINDOW_H#include <QMainWindow>class UserWindow : public QMainWindow{ Q_OBJECTpublic: UserWindow(QWidget *parent = 0); ~UserWindow();};#endif // USERWINDOW_H/********************************...原创 2021-12-11 21:24:57 · 280 阅读 · 0 评论 -
Qt学习 第5节:Qt Designer的工程文件.pro
建立一个工程,叫MyApp #-------------------------------------------------## Project created by QtCreator 2021-12-11T19:55:17##-------------------------------------------------QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = M原创 2021-12-11 20:48:03 · 551 阅读 · 0 评论 -
Qt学习 第4节:QMetaObject::connectSlotsByName(this)信号槽自动连接
#include<QApplication>#include<QHBoxLayout>#include<QSlider>#include<QSpinBox>int main(int argc,char* argv[]){ QApplication app(argc,argv); QWidget* window = new QWidget; window->setWindowTitle("Enter Your.原创 2021-12-09 21:44:53 · 550 阅读 · 0 评论