三味的小站

zint编译(VS2015)

Zint是一个强大的一、二维码生成工具 接口文档:https://zint.org.uk/Manual.aspx?type=p&page=5 zint_manual.pdf 一、下载zlib,libpng,zint zlib: https://zlib.net/fossils/ libpng:

三味线 Published on 2021-05-06

QTableView选中行文字颜色不变

表格单元格文字颜色可以通过ForegroundRole来设置,但选中高亮的颜色是另外设的,且优先级更高,好像只能通过styleSheet样式设置,想要选中时文字颜色保持不变,可以使用代理。 使用代理 class CommonDelegate : public QStyledItemDelegate

三味线 Published on 2020-12-04

Qt导出PDF(QPainter、QTextDocument)

// 添加打印支持 QT += printsupport // 包含头文件 #include <QDesktopServices> #include <QFileDialog> #include <QTextBlock> #include <QTextDocument> #include

三味线 Published on 2020-07-19

QTableView文字换行

使用QStyledItemDelegate代理手动绘制文字 #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QStyledItemDelegate> class QTableView; clas

三味线 Published on 2019-07-17

Qt Debug重定向到文本控件

Qt中可以将qDebug()输出的信息重定向通过窗口控件输出; 定义一个MsgHandlerWapper类用于转接消息: // msghandlerwapper.h #ifndef MSGHANDLERWAPPER_H #define MSGHANDLERWAPPER_H #include <QtC

三味线 Published on 2019-06-24

QGraphicsItem中添加控件

1. 直接添加到Scene QGraphicsScene *scene = new QGraphicsScene; QLineEdit *lineEdit = new QLineEdit("Hello"); QGraphicsProxyWidget *proxy = scene->AddWidget

三味线 Published on 2019-06-20

QGraphicsItem不响应mouseReleaseEvent的问题

直接重写鼠标事件,遇到的问题是:只响应press事件,而move和release事件不响应。 解决方式是将item设为selectable或movable。 //构造函数中 this->setFlag(QGraphicsItem::ItemIsSelectable); this->setAccept

三味线 Published on 2019-06-18

Qt Json简单使用

#include <QCoreApplication> #include <QJsonArray> #include <QJsonDocument> #include <QJsonObject> #include <QJsonParseError> #include <QFile> #include

三味线 Published on 2019-05-16

Qt在构造函数中退出程序(无残影)

场景 程序打开时有一个登录弹框,在主窗体构造函数中调用登录窗口,不登录直接关闭登录框时主程序退出。 实现 bool ok=mLogInDlg->exec(); if (!ok) { QTimer::singleShot(0,qApp,SLOT(quit())); } else { t

三味线 Published on 2019-04-26

Qt获取本机IP

获取所有IP #include <QNetworkInterface> #include <QHostAddress> #include <QAbstractSocket> #include <QDebug> foreach (QHostAddress addr,QNetworkInterface:

三味线 Published on 2019-04-24
Previous Next