随笔分类 -  QT

启动外部进程
摘要:#include<QProcess> QProcess 用于启动外部程序 startDetached 成员函数可以启动程序,并且跟被启动的程序脱离父子关系 QProcess pro; QStringList argv; argv.push_back("10.0.0.2"); argv.push_ba 阅读全文

posted @ 2021-07-09 09:05 lodger47 阅读(56) 评论(0) 推荐(0)

http网络访问
摘要:QNetworkAccessManager,QNetworkRequest,QNetworkReply 这三个类是Qt在网络访问比较常用的类 #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkRequest> 阅读全文

posted @ 2021-07-08 13:31 lodger47 阅读(112) 评论(0) 推荐(0)

qt MD5签名值
摘要:// 创建密码的签名值 QCryptographicHash md5_hash(QCryptographicHash::Md5); md5_hash.addData(userpwd.toUtf8()); // toHex()转换为16进制 QString md5_password(md5_hash. 阅读全文

posted @ 2021-07-08 13:27 lodger47 阅读(96) 评论(0) 推荐(0)

Json数据解析
摘要:QJsonDocument,QJsonArray,QJsonObject 这三类在解析Json数据时比较常用 使用QJsonDocument创建整体的Json数据对象 调用QJsonDocument的array函数可以返回QJsonArray的对象 遍历QJsonArray对象可以取出QJsonOb 阅读全文

posted @ 2021-07-08 11:28 lodger47 阅读(109) 评论(0) 推荐(0)

qt中json相关的操作类
摘要:// 常用类一共有四个 QJsonDocument QJsonArray QJsonObject QJsonValue // 使用json实际场景: json数据在内存, json数据在磁盘中 // 数据在磁盘文件中 1. 读磁盘文件 -> 字符串 -> json格式 2. json格式字符串 -> 阅读全文

posted @ 2021-06-03 10:02 lodger47 阅读(149) 评论(0) 推荐(0)

qt 数据库
摘要:1 在QT中 的数据库操作 在Qt中进行数据库操作需要使用的类: QSqlDataBase 属于的模块: sql 使用这个类可以创建出一个连接数据库服务器的实例 单例 相关的操作函数 // 打印qt支持的数据库驱动的名字 // QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 阅读全文

posted @ 2021-06-03 09:57 lodger47 阅读(407) 评论(0) 推荐(0)

qt 打包
摘要:![](https://img2020.cnblogs.com/blog/1843414/202105/1843414-20210521141350980-1491071631.png) 阅读全文

posted @ 2021-05-21 14:14 lodger47 阅读(42) 评论(0) 推荐(0)

qt 音效
摘要://QT +=multimedia #include <QSound> //哪里需要就放到哪里 QSound::play(":/res/TapButtonSound.wav"); 阅读全文

posted @ 2021-05-21 13:10 lodger47 阅读(76) 评论(0) 推荐(0)

qt QTableWidget函数之findItems
摘要:QList<QTableWidgetItem *> QTableWidget::findItems(const QString &text, Qt::MatchFlags flags) // 查询item项中有没有匹配的 例: bool isEmpty = ui->usrTablWidget->fi 阅读全文

posted @ 2021-05-20 22:09 lodger47 阅读(2071) 评论(0) 推荐(0)

qt animation动画
摘要:QPropertyAnimation *animation = new QPropertyAnimation(this,"geometry",this);// 属性geometry(包含x,y坐标和宽w高h坐标) animation->setDuration(100); //动画时长100毫秒 an 阅读全文

posted @ 2021-05-20 14:26 lodger47 阅读(411) 评论(0) 推荐(0)

qt UDPServer端
摘要:增加模块QT += network // 初始化属性 ui->inport->setText("8888"); ui->outport->setText("9999"); ui->localip->setText("127.0.0.1"); // 创建套接字 udp = new QUdpSocket 阅读全文

posted @ 2021-05-20 00:09 lodger47 阅读(578) 评论(0) 推荐(0)

qt 文本流&数据流
摘要:// 文本流 QFile file("aaa.txt"); file.open(QFileDevice::WriteOnly); QTextStream stream(&file); stream<<QString("hell oworld")<<123456; file.close(); // 读 阅读全文

posted @ 2021-05-19 13:36 lodger47 阅读(288) 评论(0) 推荐(0)

qt QFile点击按钮读取文件
摘要:// 点击按钮选取文件 connect(ui->pushButton,&QPushButton::clicked,[=](){ ui->textEdit->clear(); QString fileName = QFileDialog::getOpenFileName(this,"选择文件","C: 阅读全文

posted @ 2021-05-19 11:42 lodger47 阅读(1377) 评论(0) 推荐(0)

qt GBK和UTF8编码转换
摘要:QString MyWidget::GetCorrectUnicode(const QByteArray &ba) { QTextCodec::ConverterState state; QTextCodec *codec = QTextCodec::codecForName("UTF-8"); Q 阅读全文

posted @ 2021-05-19 11:34 lodger47 阅读(777) 评论(1) 推荐(0)

qt QPixmap&QImage
摘要:#include "widget.h" #include "ui_widget.h" #include <QPainter> Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(thi 阅读全文

posted @ 2021-05-19 10:54 lodger47 阅读(87) 评论(0) 推荐(0)

qt 绘画事件
摘要:// 绘图事件 void Widget::paintEvent(QPaintEvent *event) { // QPainter p(this); // QPixmap pix(":/res/PlayLevelSceneBg.png"); // // 移动画家 // p.translate(0,t 阅读全文

posted @ 2021-05-19 09:25 lodger47 阅读(115) 评论(0) 推荐(0)

qt eventFileter事件过滤器
摘要:Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { static int num=0; ui->setupUi(this); tm = new QTimer(this); tm->start(500); co 阅读全文

posted @ 2021-05-19 09:06 lodger47 阅读(123) 评论(0) 推荐(0)

qt Event事件
摘要:bool MyLabel::event(QEvent *event) { // 一般不会用来做事件拦截,通常用来做事件分发 if(event->type() == QEvent::MouseButtonPress){ QMouseEvent *ev=static_cast<QMouseEvent * 阅读全文

posted @ 2021-05-19 08:46 lodger47 阅读(144) 评论(0) 推荐(0)

qt 定时器事件QTimerEvent
摘要:方式一 #include <QTimerEvent> MyWidget::MyWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MyWidget) { ui->setupUi(this); // 启动定时器 id1 = startTimer( 阅读全文

posted @ 2021-05-19 01:22 lodger47 阅读(1087) 评论(0) 推荐(0)

QT QString
摘要:// 拼接 QString str = QString("鼠标按下了!!! x = %1 y = %2").arg(event->x()).arg(event->y()); 阅读全文

posted @ 2021-05-19 01:01 lodger47 阅读(42) 评论(0) 推荐(0)

导航