上一页 1 ··· 8 9 10 11 12 13 下一页
摘要: 文件是否有变化,以及重复,可以根据文件的Hash值来判断。 1、头文件 #include<QCryptographicHash> 2、代码 QFile file("../text.txt"); if(file.open(QIODevice::ReadOnly)) { QCryptographicHa 阅读全文
posted @ 2020-03-07 00:00 补码 阅读(2397) 评论(0) 推荐(0) 编辑
摘要: 1、bool QString::startsWith // 字符串以XX开头,返回true,第二个参数可以设置大小写敏感 QString str = "Bananas"; str.startsWith("Ban"); // returns true str.startsWith("Car"); // 阅读全文
posted @ 2020-03-06 00:30 补码 阅读(10830) 评论(0) 推荐(1) 编辑
摘要: 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 补码 阅读(1495) 评论(0) 推荐(0) 编辑
摘要: 1、头文件 #include<QHostAddress> #include<QNetworkInterface> 2、代码 1 QList<QHostAddress> list = QNetworkInterface::allAddresses(); 2 foreach(QHostAddress a 阅读全文
posted @ 2020-02-29 19:37 补码 阅读(401) 评论(0) 推荐(0) 编辑
摘要: 在做通讯练习的时候,发现发送给小助手字符乱码,图片如下 本人Qt Creator是UTF-8,需要改成gbk,代码如下 #include<QTextCodec> // 提供字符编码转换 1 QTextCodec* gbk = QTextCodec::codecForName("gbk"); 2 QS 阅读全文
posted @ 2020-02-28 17:03 补码 阅读(582) 评论(0) 推荐(0) 编辑
摘要: 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 补码 阅读(388) 评论(0) 推荐(0) 编辑
摘要: 经常用c++,qDebug()用的不习惯,将其改为cout,并且为了方便调试,还添加了文件名及行号。 代码如下: // __FILE__文件名,__LINE__行号,如果想看时间还可以添加__TIME__ #define cout qDebug() <<"["<<__FILE__<<":"<<__L 阅读全文
posted @ 2020-02-27 17:13 补码 阅读(549) 评论(0) 推荐(0) 编辑
摘要: 1、QString转换为QByteArray QString str = "123456"; QByteArray byte = str.toUtf8(); // 转换为Utf8格式 byte.toLocal8Bit(); // 转换为本机编码格式 2、QByteArray转换为char * QBy 阅读全文
posted @ 2020-02-27 16:31 补码 阅读(1204) 评论(0) 推荐(0) 编辑
摘要: 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 补码 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1、头文件 #include<QScreen> 2、代码 QScreen *screen = QGuiApplication::primaryScreen (); QRect screenRect = screen->availableVirtualGeometry(); resize(screen 阅读全文
posted @ 2020-02-27 00:44 补码 阅读(6059) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 下一页