会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
补码
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
8
9
10
11
12
13
下一页
2020年3月7日
Qt 计算Hash值
摘要: 文件是否有变化,以及重复,可以根据文件的Hash值来判断。 1、头文件 #include<QCryptographicHash> 2、代码 QFile file("../text.txt"); if(file.open(QIODevice::ReadOnly)) { QCryptographicHa
阅读全文
posted @ 2020-03-07 00:00 补码
阅读(2514)
评论(0)
推荐(0)
2020年3月6日
Qt 字符串截取常用函数
摘要: 1、bool QString::startsWith // 字符串以XX开头,返回true,第二个参数可以设置大小写敏感 QString str = "Bananas"; str.startsWith("Ban"); // returns true str.startsWith("Car"); //
阅读全文
posted @ 2020-03-06 00:30 补码
阅读(11118)
评论(0)
推荐(1)
2020年3月5日
Qt 窗口随鼠标移动(2020-11-13更新可拉伸窗口大小)
摘要: 1、原理 2、代码 1 void MyWidget::mouseMoveEvent(QMouseEvent *event) 2 { 3 QPoint P3 = event->globalPos(); 4 QPoint P2 = P3 - L; 5 this->move(P2); 6 } 7 8 vo
阅读全文
posted @ 2020-03-05 22:00 补码
阅读(1628)
评论(0)
推荐(0)
2020年2月29日
Qt获取本地IP地址
摘要: 1、头文件 #include<QHostAddress> #include<QNetworkInterface> 2、代码 1 QList<QHostAddress> list = QNetworkInterface::allAddresses(); 2 foreach(QHostAddress a
阅读全文
posted @ 2020-02-29 19:37 补码
阅读(429)
评论(0)
推荐(0)
2020年2月28日
Qt代码区字符编码转换
摘要: 在做通讯练习的时候,发现发送给小助手字符乱码,图片如下 本人Qt Creator是UTF-8,需要改成gbk,代码如下 #include<QTextCodec> // 提供字符编码转换 1 QTextCodec* gbk = QTextCodec::codecForName("gbk"); 2 QS
阅读全文
posted @ 2020-02-28 17:03 补码
阅读(631)
评论(0)
推荐(0)
2020年2月27日
Qt读写文件
摘要: 1、头文件 #include<QFile> #include<QFileDialog> #include<QDataStream> 2、写代码前工作 在ui界面拖入2个button按钮和1个textEdit,如下图所示,并分别添加button的槽函数 3、读文件 1 void MyWidget::o
阅读全文
posted @ 2020-02-27 18:07 补码
阅读(406)
评论(0)
推荐(0)
Qt的qDebug()改写为cout
摘要: 经常用c++,qDebug()用的不习惯,将其改为cout,并且为了方便调试,还添加了文件名及行号。 代码如下: // __FILE__文件名,__LINE__行号,如果想看时间还可以添加__TIME__ #define cout qDebug() <<"["<<__FILE__<<":"<<__L
阅读全文
posted @ 2020-02-27 17:13 补码
阅读(611)
评论(0)
推荐(0)
Qt的QString,QByteArray,char *相互转换
摘要: 1、QString转换为QByteArray QString str = "123456"; QByteArray byte = str.toUtf8(); // 转换为Utf8格式 byte.toLocal8Bit(); // 转换为本机编码格式 2、QByteArray转换为char * QBy
阅读全文
posted @ 2020-02-27 16:31 补码
阅读(1600)
评论(0)
推荐(0)
Qt文件发布
摘要: 1、打开Qt文件夹下的,其他版本可能为Qt (版本号)for Desktop cmd 2、将Release文件下的exe文件复制到别的文件夹,我这里为G:\Qt\QT_project\ff 3、在Qt 的cmd中切换到exe所在文件夹,并dir一下,检查是否有定位文件夹错误 4、输入windeplo
阅读全文
posted @ 2020-02-27 01:35 补码
阅读(242)
评论(0)
推荐(0)
Qt获取当前屏幕大小
摘要: 1、头文件 #include<QScreen> 2、代码 QScreen *screen = QGuiApplication::primaryScreen (); QRect screenRect = screen->availableVirtualGeometry(); resize(screen
阅读全文
posted @ 2020-02-27 00:44 补码
阅读(6482)
评论(0)
推荐(0)
上一页
1
···
8
9
10
11
12
13
下一页
公告