随笔分类 -  Qt

摘要:main.cpp中添加 #include <QDesktopWidget>QDesktopWidget* desktop = QApplication::desktop(); w.move(desktop->screenGeometry().center() - w.rect().center()) 阅读全文
posted @ 2024-12-04 15:27 夕西行 阅读(52) 评论(0) 推荐(0) 编辑
摘要:一种关闭界面彻底退出的方式,main.cpp中加入 // 启用退出锁定 QCoreApplication::setQuitLockEnabled(true); // 在应用程序退出时终止后台进程 QObject::connect(&a, &QCoreApplication::aboutToQuit, 阅读全文
posted @ 2024-09-11 16:27 夕西行 阅读(607) 评论(0) 推荐(0) 编辑
摘要:无边框,设置样式表 QMessageBox msgBox; msgBox.setStyleSheet("font-size:14px;color:red;"); msgBox.setWindowFlags( Qt::FramelessWindowHint); msgBox.setText(QStri 阅读全文
posted @ 2024-07-30 20:33 夕西行 阅读(338) 评论(0) 推荐(0) 编辑
摘要:1、QLabel Qt居中显示图片,图过大则出现滚动条(ui方式)的两种方法Label+ScrollArea、GraphicsView - 夕西行 - 博客园 (cnblogs.com) 2、QWidget+QPainter 自定义控件 QOpenGLWidget并实现缩放(纯代码) - 夕西行 - 阅读全文
posted @ 2024-03-28 16:59 夕西行 阅读(61) 评论(0) 推荐(0) 编辑
摘要:为防止不断地addItem导致内存增长,建议在初始化时new Item、scene->addItem。在合适的地方scene->removeItem(或scene->clear)或者item->setVisible。 h头文件中 #include <QGraphicsView> QGraphicsV 阅读全文
posted @ 2024-03-28 16:44 夕西行 阅读(285) 评论(0) 推荐(0) 编辑
摘要:缩放居中 QPixmap pix = QPixmap::fromImage(m_QImg); ui.label->setAlignment(Qt::AlignCenter); ui.label->setPixmap(pix.scaled(ui.label->size(), Qt::KeepAspec 阅读全文
posted @ 2023-12-22 16:35 夕西行 阅读(595) 评论(0) 推荐(0) 编辑
摘要:以保留小数点后2位为例,四舍五入 方式一 QString txt = QString("%1,%2,%3").arg(m_fAngle,0,'f',2).arg(m_fDeltaX,0,'f',2).arg(m_fDeltaY,0,'f',2); 方式二 QString txt=QString::a 阅读全文
posted @ 2023-12-18 11:04 夕西行 阅读(596) 评论(0) 推荐(0) 编辑
摘要:1、error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject 在添加Q_OBJECT后出现的错误提示。 解决:这个宏放在头文件中,而不是cpp中。 原因:QT error LNK2001: 无法解析的外部符号 "public: virt 阅读全文
posted @ 2023-12-11 17:26 夕西行 阅读(81) 评论(0) 推荐(0) 编辑
摘要:比如QVector中所有元素+1,可以用并行计算。 QtConcurrent::map():将一个函数应用于一个容器中的每一项,就地修改 items。 void add(int &num) { num +=1; } { QVector<int> vector; for(int i=0; i<3; i 阅读全文
posted @ 2023-12-09 13:35 夕西行 阅读(214) 评论(0) 推荐(0) 编辑
摘要:使用QToolBar的addWidget,添加一个可伸缩的空QWidget //Action放右侧:使用QToolBar的addWidget,添加一个可伸缩的空QWidget。 QWidget* spacer=new QWidget; spacer->setSizePolicy(QSizePolic 阅读全文
posted @ 2023-11-28 13:13 夕西行 阅读(351) 评论(0) 推荐(0) 编辑
摘要:不用到处找了,附高质量博客链接 Qt 智能指针介绍: QSharedPointer、QWeakPointer 、QScopedPointer 、QPointer(附实例)-CSDN博客 Qt智能指针信号槽连接问题_qt connect 智能指针_Jason~shen的博客-CSDN博客 阅读全文
posted @ 2023-11-24 08:15 夕西行 阅读(62) 评论(0) 推荐(0) 编辑
摘要:记录些自己用到的。 场景类(QGraphicsScene类):放置图元的容器,本身不可见。 视图类(QGraphicsView类):可视的窗口,用于显示场景中的图元。 图元类(QGraphicsItem类):各个图元的基类。直线(QGraphicsLineItem)、椭圆(QGraphicsElli 阅读全文
posted @ 2023-11-17 15:06 夕西行 阅读(61) 评论(0) 推荐(0) 编辑
摘要:QString cameraIniPath = QString::fromLocal8Bit(m_sCameraIniPath[nIndex]); 方式一 (char*)cameraIniPath.toStdString().c_str() 方式二 char sDirPath[200]; sprin 阅读全文
posted @ 2023-08-03 17:08 夕西行 阅读(31) 评论(0) 推荐(0) 编辑
摘要:对刷新率、点数、性能上要求高,对界面美观程度不是特别重视,则选QCustomPlot。 使用方法是通过添加现有文件将 qcustomplot.h、qcustomplot.cpp加入工程,并在pro文件中加入printsupport,放置widget并提升为QCustomPlot。 【官网】 Qt P 阅读全文
posted @ 2023-07-26 10:18 夕西行 阅读(105) 评论(0) 推荐(0) 编辑
摘要:x:左上角距屏幕左上角的水平距离 y:左上角距屏幕左上角的竖直距离 geometry几何属性:整个窗体的属性用frameGeometry(),客户区的属性用geometry()。 #include "QtWidgets0628.h" #include <QtWidgets/QApplication> 阅读全文
posted @ 2023-06-28 14:07 夕西行 阅读(66) 评论(0) 推荐(0) 编辑
摘要:推荐第三方的QXlsx(是对QtXlsxWriter的进一步发展,QtXlsxWriter不再更新) QtExcel/QXlsx: Excel file(*.xlsx) reader/writer library using Qt 5 or 6. Descendant of QtXlsx. (git 阅读全文
posted @ 2023-06-02 12:00 夕西行 阅读(178) 评论(0) 推荐(0) 编辑
摘要:Fontawesome提供了一些免费的图标素材,可以使用Solid样式的,比Regular样式全。 图标查找 Find Icons with the Perfect Look & Feel | Font Awesome 点击图标后(如主页图标),上方就可以看到Unicode码(16进制,以0x+Un 阅读全文
posted @ 2023-04-12 15:57 夕西行 阅读(295) 评论(0) 推荐(0) 编辑
摘要:控件缩写规范: QLabel lbl QPushButton btn QToolButton tbn QRadioButton rbn QGroupBox gb QToolBox tb QWidget wd QDialog dlg QScrollBar scb QLayout ly QListVie 阅读全文
posted @ 2023-04-04 15:14 夕西行 阅读(656) 评论(0) 推荐(0) 编辑

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