- 博客(138)
- 资源 (1)
- 收藏
- 关注
原创 C(Notes.1)
Note that if you want to initialize all elements of an array to a non-zero value(e.g.,1), you cannotuse the syntax in a[10]={1}; The statement int a[10]= {1}; will only initialize a[0] to 1,while allother elements will be initialize to 0(according to t
2024-12-12 07:35:06
127
原创 Bridge Pattern
The intent is to separate the abstraction from the implementation so that both can evolve independently.https://www.runoob.com/design-pattern/bridge-pattern.html
2024-12-10 21:01:38
315
原创 UNIX domain sockets
A UNIX socket is an inter-process communication mechanism that allows bidirectional data exchange between processes running on the same machine.IP sockets (especially TCP/IP sockets) are a mechanism allowing communication between processes over the network
2024-12-10 20:11:03
456
原创 Design Patterns
Common design pattens are typically divided into three main categories:Creational, Structural, and Behavioral. Singleton Patten. Factory Method Patten. Abstract Factory Patten. Builder Patten. Prototype Patten. Adapter Patten. Bridge Patten. Composi
2024-12-09 21:30:14
383
原创 第二章:组件、变换、布局、提高启动速度
组件就是基本元素的组合。比如按钮,用Text ,Image,MouseAread 实现一个按钮。主要有Row ,Column , Grid。TODO 后续贴上链接代码。这里主要就是矩阵变换了。TODO 后续展开了讲。
2024-11-10 16:19:58
439
原创 第一章:快速入门
在现代的软件开发中有一个内在的冲突,用户界面的改变速度远远高于我们的后端服务。Qt提供了一个典型的运行环境叫做qmlscene,但是想要写一个自定义的允许环境也不是很困难,我们需要一个快速视图(quick view)并且将QML文档作为它的资源。Qt Quick 提供了一个类似HTML声明语言的环境应用程序作为你的用户界面前端(the front-end),在你的后端使用本地的c++代码。回到我们之前的例子,在一个例子中我们使用了一个c++的城市数据模型。下面是一个简单的Qt Quick UI的例子。
2024-11-10 15:04:15
600
原创 第一章:类型推导,左值,右值
auto的使用必须马上初始化,否则无法推导出类型auto在一行定义多个变量时,各个变量的推导不能产生二义性,否则编译失败auto不能用作函数参数在类中auto不能用作非静态成员变量auto不能定义数组,可以定义指针auto无法推导出模板参数decltype推导规则对于decltype(exp)有exp是表达式,decltype(exp)和exp类型相同exp是函数调用,decltype(exp)和函数返回值类型相同。
2024-11-10 12:32:02
849
原创 day2 生成lua代码
在实际应用中,你可能需要更复杂的交互和功能,以及涉及 Node.js 和 C++ 之间的数据传递和类型转换等处理。要在 Node.js 中调用 C++ 代码,可以使用 node-addon-api 这样的工具来创建一个 C++ 的扩展模块。首先,创建一个名为 addon.cpp 的 C++ 文件,其中包含要导出到 Node.js 的函数。然后,创建一个名为 binding.gyp 的文件,用于构建 Node.js 扩展模块。运行 index.js 文件,将会输出 5,表示成功调用了 C++ 函数。
2023-12-18 09:40:25
936
原创 QWidget 实现原理调查
前言QWidget实际上就是个壳,用来标记脏区域,处理一些事件。1、首先update, repaint 最终都调用QWidgetPrivate::syncBackingStore,2、QWidgetPrivate::syncBackingStore 相关流程,最终调用endPaint进入平台层 , 调入void QFbBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset)1
2022-04-06 11:23:15
800
原创 嵌入式Qt踩过的坑 (1- 30)
一、scence/view,QWidget, QQuick框架选择问题1、QQuick虽然支持GPU渲染,但是,在不支持GPU的屏上表现效率比QWidget差。2、scence/view框架,除了需要浮点计算支持,void QGraphicsProxyWidget::setWidget(QWidget *widget) 整合QWidget,更是把效率拉跨到了极限。3、QWidget,中规中矩,能解决绝大部分需求。强烈推荐二、setStyleSheet这个函数也是十分消耗性能的,不建议频繁调用。
2022-03-17 10:03:16
1316
原创 Qt的一些用法(31-40)
三十一 、遮罩的实现遮罩可以用来设置窗口的颜色class MaskForm : public QWidget{ Q_OBJECTpublic: explicit MaskForm(QWidget *parent = 0) : QWidget(parent) { init(); } ~MaskForm(){}; /** * @brief 设置遮罩的颜色,透明度 * @param color 遮罩颜色
2021-12-21 09:56:38
680
原创 关于mousePressEvent, mouseReleaseEvent,mouseDoubleClickEvent遇到的坑
#include "mainwindow.h"#include "ui_mainwindow.h"#include <QDebug>#include <QGraphicsView>#include <QGraphicsScene>#include <QMouseEvent>#include <QGraphicsSceneMouseEvent>#include <QApplication>class GraphicsVie
2021-12-03 18:00:17
2439
原创 setCodecForLocale影响哪些函数?
当我们从程序的命令行读取参数时int main(int argc, char *argv[])当我们从往控制台输出内容时qDebug()<<QString(…)使用 QString::fromLocal8Bit() 与 QString::toLocal8Bit()QFile 传入参数文件名
2021-11-26 15:05:16
237
原创 QScrollBar完整的样式表
一、水平滚动条QScrollBar:horizontal { border: 2px solid grey; background: #32CC99; height: 15px; margin: 0px 20px 0 20px; } QScrollBar::handle:horizontal { background: white; min-width: 20px; } QScrollBar::add-line:hor
2021-10-26 16:25:49
4266
原创 Qt之根据图片计算绘制区域
QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const{ QRect result; int x, y, w, h; rect.getRect(&x, &y, &w, &h); const int pixmapWidth = pixmap.width()/pixmap.devicePixelRati
2021-10-26 14:10:05
275
原创 Qt之根据字符串计算绘制区域
QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled, const QString &text) const{ QRect result; int x, y, w, h; rect.getRect(&x, &y, &w, &h);
2021-10-26 13:56:58
373
原创 基于QCustomplot实现帕累托图
什么是帕累托图?相关代码void MainWindow::setParetoDemo(QCustomPlot *customPlot){ demoName = "Bar Chart Demo"; // set dark background gradient: QLinearGradient gradient(0, 0, 0, 400); gradient.setColorAt(0, QColor(90, 90, 90)); gradient.setColorA
2021-10-21 14:16:03
256
原创 QML自定义实现ScrollBar
import QtQuick 2.6/* 滚动条-竖向滚动条可配合 Qt ListView ,Qt Flickable ,等等使用。 TScrllbarV{ target:listView; }*/Item { id:toou2d_scrollbarv; width: 22; property Flickable target: parent; //0 - 1 property double yPosition: 0; //可变小
2021-09-15 17:24:01
1003
原创 Qt的一些用法(21-30)
二十一、如何在Item view中设置Icon的大小。使用setIconSize 即可。int main(int argc, char *argv[]){ QApplication app(argc, argv); QTableWidget box; box.horizontalHeader()->setStretchLastSection(true); QPixmap pix(50,50); pix.fill(Qt::red); QIcon ic
2021-09-08 18:12:19
760
原创 Qt的一些用法(11-20)
十一、QComboBox宽度偏小,如何显示全下拉文本项。 QComboBox *combo = new QComboBox(this); combo->view()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); combo->addItem("Combo box entry number 1"); combo->addItem("Combo box entry number 2"
2021-09-07 14:13:33
1171
原创 Qt的一些用法(1-10)
一、使用插件的好处?二、跨线程调用函数?How can I invoke functions on QObjects from another thread?方法1:void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority)方法2:使用信号和槽函数三、如何鼠标旋转QGraphicsItem?1、GraphicsEllipseItem#ifnde
2021-09-06 13:51:12
401
原创 QTextEdit中跳转到指定行
TextEdit中跳转到指定行1、原理说明:首先,要得到 一个鼠标指针对象:QTextCursor tc = textCursor();然后利用QTextCursor的setPosition函数设置鼠标指针的位置。这里的position是指整个文件流的位置坐标,如何定位到行呢?以前也被这个问题困扰解决的办法是:利用QTextBlock这类。可以理解为块数据,因为文件中的Block是以换行符分割,所以可以看成是文件的一行。那么利用QTextDocument的findBlockByNumber 函数就可以得
2021-09-03 10:12:15
1961
原创 QML使用QPainter
一、谈谈QPainter如果能良好的使用QPainter,那Qt已经入门一半了。QPainter如此神奇,好比神笔马良的画笔,能够实现你能看到的所有2D控件。无论是搭配QWidget, 还是搭配QGraphicsItem, 甚至搭配QQuickItem,都能实现你想要的控件。二、说说QPainter在QQuickItem中实现的原理首先要使用QPainter,那么QQuickPaintedItem必不可少。继承自QQuickItemQQuickItem,是依赖QSG框架实现的,通过QSGNode
2021-09-01 20:01:40
647
原创 QML 封装使用SVG 和Iconfont
直接上代码1、使用SVG图import QtQuick 2.6/* https://www.iconfont.cn svg 是一种比较流行的icon 源。 默认是异步加载的,可提高性能。 因为需要寻找svg资源,这点没有AwesomeIcon 方便。*//*! TODO */Item { id:toou2d_svgicon width: 16; height: 16; property bool asynchronous : true;
2021-08-31 17:29:38
2179
原创 Qt使用技巧
1、QListWidgetQListWidgetItem使用setData、data存储、使用数据。实际上有一个QList values队列,可以按照数据类型进行存储使用
2021-08-12 19:08:34
140
原创 QVariant的使用
关于QVariant的使用,主要从三个方面进行说明1、QVariant支持的类型,如,int, float, QString等 QVariant var=12; int data=var.toInt();2、自定义类型,这个时候就要用到Qt的元对象系统。Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant struct MyC
2021-08-02 10:32:32
423
原创 QML之实用技巧
1. 使用get函数获取QQuickItem封装类的私有属性类 auto item = new QQuickItem(); auto prv = QQuickItemPrivate::get(item); prv ->anchors()->setFill(root);
2021-07-28 10:46:21
182
QtPluginDemo.rar
2020-11-20
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人