- 博客(92)
- 收藏
- 关注
原创 Qt如何直接处理系统事件(比如鼠标事件),而不是post事件
直接再 qWindowsWndProc函数中处理。通常情况: 事件被放到一个队列中。
2024-03-22 13:43:01
404
原创 结局QMenu中“checkable的QAction“ 和 “无checkable的QAction“的文字对齐问题
QMenu::item{padding-left: 20;padding-right:50;padding-top:5;padding-bottom:5;color: rgb(215,215,215);font-size:12px;}QMenu::item:checked, QMenu::item:unchecked{padding-left: 7;}QMenu::indicator{width: 13px;height: 13px;}理解思路:1.in.
2022-05-19 16:01:49
687
1
原创 解决QGraphicsView中橡皮筋风格
#ifndef RUBBERBANDSTYLE_H#define RUBBERBANDSTYLE_H#include <QBrush>#include <QPainter>#include <QPen>#include <QProxyStyle>#include <QRect>#include <QStyleOptionRubberBand>class RubberbandStyle : public QProxy.
2022-02-18 17:12:08
644
原创 直接继承QWidget时,qss样式表失效的解决方案
Qt帮助文档搜索:Qt Style Sheets ReferenceQWidget Supports only the background, background-clip and background-origin properties.If you subclass from QWidget, you need to provide a paintEvent for your custom QWidget as below: void CustomWidget::paintEvent..
2021-12-28 15:45:33
390
原创 TIFF文件中 TIFFTAG_PHOTOSHOP的解析
参考FreeImage3180 中E:\project_3rd\project_freeImage\FreeImage3180\FreeImage_msvc2019\Source\FreeImage\PluginTIFF.cpp 中 第 1314行 psdParser
2021-12-16 09:43:30
604
原创 Qt笔记 - 杂记
//获取省略文字QString txt = tb->fontMetrics.elidedText(tb->text, Qt::ElideRight, tr.width()); QRect textRect = style()->subElementRect(QStyle::SE_TabBarTabText, option, this); option->text = fontMetrics().elidedText(option->text, d->.
2021-12-10 10:10:19
308
原创 c++11 future 与 thread_local 的问题
#pragma once#include <iostream>#include <thread>#include <vector>#include <memory>#include <future>using std::cout;using std::endl;class Test_threadLocal{ typedef Test_threadLocal self_type; class ThreadL.
2021-12-09 11:15:30
460
原创 QGraphicsView的mapFromScene(QPointF) 返回的是QPoint,丢失了精度,怎么办?
const QPoint posInt = ui->graphicsView_->mapFromScene(pos); qDebug() << "posInt" << posInt; // 使用 viewportTransform().map const QPointF posReal = ui->graphicsView_->viewportTransform().map(pos); qDebug() <&l...
2021-11-10 09:23:33
515
原创 文件映射的思考与实验 (映射过大,导致内存使用率非常高)
void ThinkOne::test_multi_file_release_source(){ try { const size_t fileCount = 256; const size_t totalFileBytes = 1024ull * 1024ull * 1024ull * 16ull; const size_t fileBytes = totalFileBytes / fileCount; H.
2021-08-31 16:04:24
1575
原创 QLineEdit,QPlainTextEdit,QTextEdit 选中背景色和选中颜色qss
nameEdit->setStyleSheet("color: blue;" "background-color: yellow;" "selection-color: yellow;" "selection-background-color: blue;");color: 未选中时字体颜色selection-color:选中时字体颜...
2021-08-18 09:02:50
4521
原创 Qt之向大佬学习
1.刘典武的https://github.com/feiyangqingyun/qtkaifajingyan总结了很多Qt中一些小细节。
2021-08-10 10:41:06
862
原创 二维码详解
1.libqrencode下载:https://fukuchi.org/works/qrencode/参考:https://www.cnblogs.com/LiuYanYGZ/p/12718058.html
2021-08-09 13:42:19
106
原创 汉化QColorDialog
//汉化 QColorDialog QTranslator translator; if (translator.load("qt_zh_CN.qm", QCoreApplication::applicationDirPath() + "/translations")) a.installTranslator(&translator);在源码中目录中找到 目录translations下的 qt_zh_CN.qm (依然存在问题:有几个控件依旧是 英文)...
2021-08-07 16:44:17
735
原创 借鉴boost中的宏定义
文件 boost_1_74_0\boost\config\auto_link.hpp#if defined( _M_IX86 )# define BOOST_LIB_ARCH_AND_MODEL_OPT "-x32"#elif defined( _M_X64 )# define BOOST_LIB_ARCH_AND_MODEL_OPT "-x64"#elif defined( _M_ARM )# define BOOST_LIB_ARCH_AND_MODEL_OPT "-a32"#e...
2021-07-14 09:23:21
341
原创 msvc2019使用filesystem
1.如果使用msvc默认设置#include <experimental/filesystem>2.如果 c/c++ ==> 语言 ,更改c++语言标准#include <filesystem>
2021-07-06 08:42:35
835
原创 msvc中debug模式使用release第三方库时注意事项
msvc中debug模式使用release第三方库时,注意事项:链接器 --> 输入 -->忽略特定默认库: msvcrt.lib
2021-05-07 08:25:46
1065
原创 QFileSystemModel
借鉴:https://www.devbean.net/2013/02/qt-study-road-2-qfilesystemmodel/ auto model = new QFileSystemModel(); model->setRootPath("D:/Maintop/MtComposeDesigner/TemplateRoot"); model->rootPath(); ui->treeView_->setModel(model);.
2021-03-01 14:54:12
147
原创 Qt中让MainWindow出现模态窗口的效果
qDebug() << "begin"; auto pMyMainWindow = new MyMainWindow(this); pMyMainWindow->setWindowModality(Qt::WindowModal); // pMyMainWindow->setWindowModality(Qt::ApplicationModal); //关闭后自动释放窗口,不需要自己释放pMyMainWindow pM...
2021-02-06 11:00:00
1108
2
原创 QToolBar中的“更多“按钮的样式设置
QToolBar在加入很多QAction后会出现">>"按钮,当点击该按钮后,会出现菜单,而该按钮icon是黑色的">>"不适合我们系统,所以对该按钮进行了样式处理。而对于设置这个按钮的样式和图片有以下两种方法设置:QToolBar QToolBarExtension{qproperty-icon:url('image.png');}QToolBar #qt_toolbar_ext_button{qproperty-icon:url('image.png');}查看源
2021-01-29 10:46:13
1237
原创 std::string查找功能比较强大
char szContent[] = { '\x00','\x00', '\x3f','\x00','\xf0','\x80','\x00','\x3f','\x00','\xf0','\x00','\x3f','\x00','\xf0' }; std::string strContent; for (int i = 0; i < sizeof(szContent); ++i) { strContent.push_back(szContent[i]);...
2020-12-17 16:06:01
461
原创 无符号与有符号互相转化时,遇到的奇怪现象 (今后要注意)
int8_t i8 = 0x97; uint32_t u32 = i8; int8_t i8_1 = 0x0a; uint32_t u32_1 = i8_1; uint8_t ui8_1 = 0x97; uint32_t u32_2 = ui8_1;
2020-12-17 16:02:56
249
原创 QLineEdit过滤掉特殊字符
/* * 很奇怪:输入 \ ,打印文本为 \\, * 正则表达式用\\\\ 来表示\\ ,防止用户 输入 \ */ QRegExp rx = QRegExp("[^\\\\/:*?\"<>|]*"); //限制以下特殊符号在lineEdit中的输入 QRegExpValidator* validator = new QRegExpValidator(rx); ui->lineEdit_templateName_->setV...
2020-11-13 09:47:19
2784
2
原创 c++大型整数乘积溢出,注意给值后面添加 ui64 i64等后缀
uint64_t n1 = 1000 * 1000 * 1000 * 1000; (错误) uint64_t n2 = (uint64_t)1000 * (uint64_t)1000 * (uint64_t)1000 * (uint64_t)10; uint64_t n3 = 1000ui64 * 1000ui64 * 1000ui64 * 10ui64;
2020-09-16 11:43:51
662
原创 Qt使用Vld时,有一种情况无法检测出内存泄露
自己猜测的原因:在main函数开头,调用 QFileDialog::getOpenFileName 后,导致dll卸载有问题。(本人尝试过 自己写的dll,卸载时应该打印相应的日志,但实际情况却没有 打印日志。)在main函数 开头,不调用该函数,一切正常...
2020-09-11 10:23:55
693
1
原创 boost mpi库编译
1.下载msmpisdk.msimsmpisetup.exe下载地址:https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi?redirectedfrom=MSDN2.安装 注意事项:安装时,一定要使用默认的安装目录。原因:因为boost的E:\boost_install\boost_1_74_0\tools\build\src\tools\mpi.jam 文件中的目录是“安装时的默认目录...
2020-09-10 15:56:43
939
2
原创 QtCreator各种疑难杂症
1.Qtcreator 创建 新文件时 大小写https://blog.youkuaiyun.com/lvmengzou/article/details/103289332关键字:菜单 [ 工具--> 选项 -->C++-->文件命名-->lower case file names勾选框去掉 ]
2020-08-24 15:04:19
511
原创 msvc链接库技巧
#if defined(_WIN64) && defined(_WIN32)#define PlatformTarget "x64"#else#define PlatformTarget "x86"#endif#if (_MSC_VER == 1600)#define PlatformToolset "v100"#elif (_MSC_VER == 1700)#define PlatformToolset "v110"#elif (_MSC_VER == 1800)#d
2020-05-22 19:40:01
345
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人