2021年7月19日
摘要: 1、绑定信号与槽 QObject::connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(changeStackWidget(int))); 2、实现槽函数 ui->stackedWidget->setCurrentIn 阅读全文
posted @ 2021-07-19 10:45 缘随风烬 阅读(637) 评论(0) 推荐(0) 编辑
  2021年7月17日
摘要: 1、写配置文件 QSettings settings(filePath, format) // 所要创建文件的路径, 参数二为创建文件的格式 QSettings settings("Option.ini", QSettings::IniFormat); // 当前目录的INI文件 settings. 阅读全文
posted @ 2021-07-17 23:07 缘随风烬 阅读(1133) 评论(0) 推荐(0) 编辑
  2021年7月16日
摘要: QString::number(str, 'f', 2); QString::number(str, ‘g’, 2); // 保留2位有效数字,并采用简单方式表示,部分情况采用科学计数法表示 阅读全文
posted @ 2021-07-16 16:03 缘随风烬 阅读(794) 评论(0) 推荐(0) 编辑
摘要: 在pro文件中,添加 DESTDIR = 路径 最终会在指定路径下生成一个exe文件 阅读全文
posted @ 2021-07-16 16:00 缘随风烬 阅读(1908) 评论(0) 推荐(0) 编辑
摘要: 1、打印当前行和文件名 #define FILE_NAME __FILE__ #define LINE_COUNT __LINE__ 在需要打印的位置打印信息 qDebug() << FILE_NAME<<LINE_COUNT; 阅读全文
posted @ 2021-07-16 15:54 缘随风烬 阅读(266) 评论(0) 推荐(0) 编辑
摘要: QString str = "1, 2, 3,4,5"; QStringList list = str.split(","); for(int i = 0; i < list.size(); i++){ qDebug() << list.at(i); } // 1 2 3 4 5 阅读全文
posted @ 2021-07-16 15:39 缘随风烬 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1、头文件 #include <QVector> 2、使用格式 QVector<类型> 对象 例如: QVector<int> a; QVector<QString> b; 3、向容器中添加内容 a.append(1) a.append(2) a.insert(0, 3) //第一个参数代表的是插入 阅读全文
posted @ 2021-07-16 14:13 缘随风烬 阅读(4643) 评论(0) 推荐(0) 编辑
摘要: 1、绘制多边形 利用 paintEvent(QPaintEvent *event)绘图事件 void 类名::paintEvent(QPaintEvent * event) { Q_UNUSED(event); QPainter painter(this); // 设置画笔颜色 painter.se 阅读全文
posted @ 2021-07-16 10:50 缘随风烬 阅读(686) 评论(0) 推荐(0) 编辑
  2021年5月28日
摘要: .h文件 #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QTcpSocket> #include <QTimer> namespace Ui { class MainWindow; } class 阅读全文
posted @ 2021-05-28 11:23 缘随风烬 阅读(713) 评论(0) 推荐(0) 编辑
  2021年5月14日
摘要: 1、解析 QFile file(ui->comboBox->currentText()); //打开文件 bool isOK = file.open(QIODevice::ReadOnly | QIODevice::Text); if(isOK){ QXmlStreamReader reader(& 阅读全文
posted @ 2021-05-14 17:18 缘随风烬 阅读(814) 评论(0) 推荐(0) 编辑