随笔分类 -  QT

摘要:简单用法QWaitCondition 用于多线程的同步,一个线程调用QWaitCondition::wait() 阻塞等待,直到另一个线程调用QWaitCondition::wake() 唤醒才继续往下执行。 为了描述方便,这里假设主线程调用Send()往通信口发送一个数据包,然后阻塞等待回包才继续 阅读全文
posted @ 2022-09-20 17:16 cicero 阅读(337) 评论(0) 推荐(0) 编辑
摘要:转自:http://blog.sciencenet.cn/blog-562235-1083517.html 编译Qt时,Qt路径极被hard-code到Qt库里面去了(见下文详细描述)。此时如果更改Qt路径(比如将已编译好的库挪动),极有可能出现找不到plugin,甚至找不到Qt库的错误。遇到类似问 阅读全文
posted @ 2021-03-15 15:33 cicero 阅读(1610) 评论(0) 推荐(0) 编辑
摘要:qt5 中文乱码,可以在程序中设定使用的字体和编码 QApplication a(argc, argv); //设置中文字体 // a.setFont(QFont("wenquanyi", 16)); int id = QFontDatabase::addApplicationFont("./msy 阅读全文
posted @ 2020-11-19 16:42 cicero 阅读(257) 评论(0) 推荐(0) 编辑
摘要:重写函数 void contextMenuEvent(QContextMenuEvent *) void contextMenuEvent(QContextMenuEvent *) { QMenu menu; QAction *addAction = menu.addAction(tr("Add D 阅读全文
posted @ 2020-10-20 16:19 cicero 阅读(527) 评论(0) 推荐(0) 编辑
摘要:转:https://blog.csdn.net/qq_15821883/article/details/100096659?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.ed 阅读全文
posted @ 2020-08-19 11:14 cicero 阅读(1493) 评论(0) 推荐(0) 编辑
摘要:参考文章: https://blog.csdn.net/litao31415/article/details/100144400?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7 阅读全文
posted @ 2020-06-30 18:19 cicero 阅读(511) 评论(0) 推荐(0) 编辑
摘要:编译qt时。configure 添加选项 -qt-freetype 代码增加: //设置中文字体 a.setFont(QFont("wenquanyi", 16)); //设置中文编码 #if _MSC_VER QTextCodec *codec = QTextCodec::codecForName 阅读全文
posted @ 2020-06-30 13:41 cicero 阅读(464) 评论(0) 推荐(0) 编辑
摘要:QMessageBox::StandardButton rb = QMessageBox::information(NULL, tr("Warnning!"), tr("The Application is running?"), QMessageBox::Yes|QMessageBox::No|Q 阅读全文
posted @ 2020-05-20 16:01 cicero 阅读(206) 评论(0) 推荐(0) 编辑
摘要:int strwidth = painter.fontMetrics().width(strTxt);//字符串显示的像素大小 painter.drawText(this->width()/2-strwidth/2,this->height(),m_strTxt); 或者painter.drawTe 阅读全文
posted @ 2020-04-15 15:35 cicero 阅读(971) 评论(0) 推荐(0) 编辑
摘要:#include <QApplication> //添加头文件 #include <qdebug.h> #include <QSqlDatabase> #include <QSqlError> #include <QSqlQuery> int main(int argc, char *argv[]) { QApplication a(argc, argv); //建立并打开数据库 QSqlData 阅读全文
posted @ 2019-12-24 10:06 cicero 阅读(1085) 评论(0) 推荐(0) 编辑
摘要:原文: https://my.oschina.net/u/3919756/blog/1944747 如果我们用painter一个一个的绘制直线,圆等在控件上,绘制效率会不高。为了提高效率,我们可以设置一个画布pixmap,将所有的基础图形画布上,然后把画布画在控件上。 阅读全文
posted @ 2019-11-28 15:59 cicero 阅读(1551) 评论(0) 推荐(0) 编辑
摘要:setStyleSheet 为以下字符串,选中,未选中,有焦点,无焦点时显示不一样的图片 阅读全文
posted @ 2019-11-21 13:39 cicero 阅读(2340) 评论(0) 推荐(0) 编辑
摘要:https://doc.qt.io/archives/qt-4.8/stylesheet-examples.html //下面是设置垂直滚动条的样例 QString strStyle = QString(" \ //设置整体的颜色 QSlider\ {\ background-color: %2;\ 阅读全文
posted @ 2019-10-24 10:10 cicero 阅读(1870) 评论(0) 推荐(0) 编辑
摘要:setStyleSheet( "QProgressBar{border:1px solid #FFFFFF;" "height:30;" "background:grey;" "text-align:right;" "color:rgb(255,255,255);" "border-radius:0px;}" "QProgressBar::chunk{" "border-radius:5px;" 阅读全文
posted @ 2019-10-15 15:00 cicero 阅读(3731) 评论(0) 推荐(0) 编辑
摘要:方法1: 主要通过计时器,在一段时间内的连续两次单击,触发双击事件 方法2: 方法3: 阅读全文
posted @ 2019-09-20 14:00 cicero 阅读(1226) 评论(0) 推荐(0) 编辑
摘要:MainWindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QTimer> class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); ~MainWindow(); 阅读全文
posted @ 2019-09-18 14:51 cicero 阅读(1108) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示