qt5

QPainter and OpenGL native code in QOpenGLWidget class

落爺英雄遲暮 提交于 2020-01-23 11:08:22
问题 I am preparing a desktop application to draw some 2D plots. I am using C++: Qt 5 and visual studio 2013. I created a simple GUI and put myQOpenGLWidget in it. I am already drawing the plots, axes and ticks using my own openGl shaders. Everything works fine and now I want to add the description to my axes and ticks to make the graph possible to analysis. As in OpenGL itself there is no dedicated functions to render text, I came up with using QPainter object just to add the desired description

How to detect QObject::moveToThread() failure in Qt5?

强颜欢笑 提交于 2020-01-23 01:10:06
问题 The documentation on QObject::moveToThread() for Qt5.3 explains that the moveToThread() method can fail if the object has a parent. How would I detect this failure in my code? I realize that simply making sure that my object does not have a parent first is probably good enough, but as a defensive programming practice I would like to test the return value from all calls that may fail. EDIT: I want to stress here after some answers that I am fully aware that I can test if parent is 0 before

Qt 5.8 and Pdf.js error

China☆狼群 提交于 2020-01-21 23:02:21
问题 I have a problem with pdf.js and Qt 5.8, i tried to do the same code in this link Using pdf.js with Qt5.8 in my application but he doesn't work i dont know why, qt show me this message about JS : "js: Uncaught TypeError: Cannot read property 'PDFJS' of undefined". this is my code in mainwindow : QWebEngineView *view; QString pdfFileURL; QString pathToPDFjs = QString("file:///"+qApp->applicationDirPath()+"/libraries/PDF/viewer.html"); pdfFileURL = "file:///C:/Users/Administrateur/Desktop/CV

Qt 5.8 and Pdf.js error

陌路散爱 提交于 2020-01-21 23:02:07
问题 I have a problem with pdf.js and Qt 5.8, i tried to do the same code in this link Using pdf.js with Qt5.8 in my application but he doesn't work i dont know why, qt show me this message about JS : "js: Uncaught TypeError: Cannot read property 'PDFJS' of undefined". this is my code in mainwindow : QWebEngineView *view; QString pdfFileURL; QString pathToPDFjs = QString("file:///"+qApp->applicationDirPath()+"/libraries/PDF/viewer.html"); pdfFileURL = "file:///C:/Users/Administrateur/Desktop/CV

Qt 5.8 and Pdf.js error

时光总嘲笑我的痴心妄想 提交于 2020-01-21 23:01:38
问题 I have a problem with pdf.js and Qt 5.8, i tried to do the same code in this link Using pdf.js with Qt5.8 in my application but he doesn't work i dont know why, qt show me this message about JS : "js: Uncaught TypeError: Cannot read property 'PDFJS' of undefined". this is my code in mainwindow : QWebEngineView *view; QString pdfFileURL; QString pathToPDFjs = QString("file:///"+qApp->applicationDirPath()+"/libraries/PDF/viewer.html"); pdfFileURL = "file:///C:/Users/Administrateur/Desktop/CV

Qt5 教程

孤者浪人 提交于 2020-01-20 21:13:07
序 Qt 前言 Hello, world! 信号槽 自定义信号槽 Qt 模块简介 MainWindow 简介 添加动作 资源文件 对象模型 布局管理器 菜单栏、工具栏和状态栏 对话框简介 对话框数据传递 标准对话框 QMessageBox 深入 Qt5 信号槽新语法 文件对话框 事件 (点击显示鼠标位置坐标) 事件的接受与忽略 event() 事件过滤器 事件总结 自定义事件 Qt 绘制系统简介 画刷和画笔 反走样 渐变 坐标系统 绘制设备 Graphics View Framework 贪吃蛇游戏(1) 贪吃蛇游戏(2) 贪吃蛇游戏(3) 贪吃蛇游戏(4) 文件 二进制文件读写 文本文件读写 存储容器 遍历容器 隐式数据共享 model/view 架构 QListWidget、QTreeWidget 和 QTableWidget QStringListModel QFileSystemModel 模型 视图和委托 视图选择 QSortFilterProxyModel 自定义只读模型 自定义可编辑模型 布尔表达式树模型 使用拖放 自定义拖放数据 剪贴板 数据库操作 使用模型操作数据库 可视化显示数据库数据 编辑数据库外键 使用流处理 XML 使用 DOM 处理 XML 使用 SAX 处理 XML 保存 XML 使用 QJson 处理 JSON 使用 QJsonDocument 处理

Qt5 新特性

雨燕双飞 提交于 2020-01-20 20:46:23
Qt 5 已经临近发布,其最大的特点就是模块化。将原来庞大的模块更细分为不同的部分,同时,一个大版本的升级,当然少不了添加、删除各个功能类。文本简单介绍 Qt5 的特性,其具体内容来自 Qt5 官方 Wiki 的介绍 。 前面说过,Qt5 最大的特性在于模块化。这么多的模块,Qt5 统称为 Qt Essentials。下面就来看看这些模块究竟是什么吧!注意,有些模块没有在这里列出,例如 SQL 等。请在 这里 查看完整的 Qt5 模块列表。 Qt Core Qt Core 类似于 Qt4 中的 QtCore 模块,包含了所有非 GUI 的功能。所有其他的 Qt 模块都基于这个模块。与 Qt4 的 QtCore 不同之处在于,Qt Core 还包括了 XML 等 Qt4 中存在的部分。 QStandardPaths QStandardPaths 是 Qt4 的 QDesktopServices 的增强版,其 API 大部分基于 KDE4 的 KStandardDirs 。这个类提供了比 QDesktopServices 更多的功能,例如在某一存储位置搜索给定文件等。 MimeTypes QMimeDatabase 提供了判断给定文件或内存区块的 mimetype 的功能,原理是通过扩展名和(或)内容信息。 MIME 类型数据库由 freedesktop.org 的 shared

Intercepting Tab key press to manage focus switching manually

被刻印的时光 ゝ 提交于 2020-01-20 04:18:55
问题 I want to intercept Tab key press in my main window to prevent Qt from switching focus. Here's what I've tried so far: bool CMainWindow::event(QEvent * e) { if (e && e->type() == QEvent::KeyPress) { QKeyEvent * keyEvent = dynamic_cast<QKeyEvent*>(e); if (keyEvent && keyEvent->key() == Qt::Key_Tab) return true; } return QMainWindow::event(e); } This doesn't work, event isn't called when I press Tab . How to achieve what I want? 回答1: The most elegant way I found to avoid focus change is to

QPushButton not blinking

时间秒杀一切 提交于 2020-01-17 16:39:40
问题 Inspired by Label on QToolBar, possible? I'm trying to develop it. But my button do not blink on click, why? I see in the other app looks like the button color gets gray during the click (while pressed) and the normal button gets blue. But my button which is just all an image don't have any behavior during the click. On the left side is the toolbar using QAction (question linked above) and on the right side is the code below. QApplication a(argc, argv); QMainWindow w; QToolBar barA; barA

Qt5.5 How to override MousePress event coordinates at Application level

帅比萌擦擦* 提交于 2020-01-17 13:46:12
问题 I'm developing an application on a small Embedding Linux device with Qt5.5. I need to be able to modify the mouse press coordinates received from Linux ( tslib ) in my application. I've tried implementing an event filter in my main view that modifies the mouse coordinate received, creates a new mouse event and submits the new event to the widget. However, in the widget's mousePressEvent function, I see the debug message only once, and it is for the original coordinates received, not my