qt5

How to build an API with QJSEngine?

余生长醉 提交于 2019-12-13 12:15:30
问题 I am starting with Qt and one of my projects is using QJSEngine to evaluate javascript and I want to provide an entire API to the script, with classes and global functions. Right now my program provides only the ECMAScript default stuff (eval, encodeURI, parseInt, etc...), but I need to expose some custom classes to the code, like the browsers API (WebSocket class, Image class, document object). For example: var obj = new CustomClass("", 0); var ret = obj.customClassMethod("[...]!");

Qt5-QML: How to handle a combobox in QML via JavaScript

╄→尐↘猪︶ㄣ 提交于 2019-12-13 10:52:06
问题 I am accessing to my own robots via wi-fi using a third party router. I wrote a small application that automatically log-in to the router, navigate through the tab of the router interface all using JavaScript inside a QML application. The small problem I have is that I have to trigger a relays to turn on/off the robot and inside the router GUI I need to trigger a combobox as shown in the print screen below. After clicking on the I/O tab, the address of the router page is https://123.456.789

Adding Qt Dependencies to spec file in rpmbuild

早过忘川 提交于 2019-12-13 10:21:28
问题 I'm using Ubuntu 14.04 and I am updating the rpmbuild spec file of an application that now uses Qt. The packages that I need are the following: sudo apt-get build-essential sudo apt-get install mesa-common-dev -y sudo apt-get install libglu1-mesa-dev -y sudo apt-get qt5-default sudo apt-get qtwebengine5-dev I know the spec file has "BuildRequires" and "Requires" dependency tags...any help in writing this as well as some examples would be helpful. I have a working spec file I just need to add

Render TO and WITH texture using QOpenGLTexture and QOpenGLFramebufferObject

二次信任 提交于 2019-12-13 07:20:00
问题 According to the document of QOpenGLTexture in Qt5, one can render WITH texture, and can also render TO texture. Is there any simple example about these two usages? The scenario of such usages could be found at this link. The problematic codes about this are listed below: In the offscreen part: Initialization of offscreen rendering: p_offscreen_context_ = std::make_unique<QOpenGLContext>(); p_offscreen_context_->setFormat(_p_onscreen_context->format()); // _p_onscreen_context is the context

Editable reorderable (by drag and drop) Qt5 QTreeView example

主宰稳场 提交于 2019-12-13 05:43:21
问题 after being unable to find a decent generic hierarchical reorderable drag and drop example for Qt5's QTreeView, I tried to transform the Editable Tree Model example code accordingly. There's an related question recorded at: QTreeView with drag and drop support in PyQt, but while it's PyQt4, which isn't a problem in itself (I'm going to convert this to PyQt anyway ;)), the treeview + abstract model doesn't work properly. At least, it doesn't reorder any items here. This example code doesn't

print out all the requested URLs during loading a web page

只谈情不闲聊 提交于 2019-12-13 05:38:19
问题 In my project, there is some need to get a certain requested URL in Chrome Dev Tools by Python during loading a web page, I think get the URL by Qt WebEngine is a good solution. I started by trying to use the code below to print out all the requested URLs during loading a web page, but it didn't work - no URL get printed at all , so what's wrong here ? Any good solutions ? import sys import os from PyQt5.QtWidgets import QApplication from PyQt5.QtWebEngineWidgets import * from PyQt5

How to register for ACTION_VIEW Intent on Android? Why doesn't my QApplication receive QEvent::FileOpen events?

和自甴很熟 提交于 2019-12-13 05:23:43
问题 I am trying to register a QtQuick Android application to open a certain class of files and handle them. From what I gather, when a file is opened with a QApplication it results in a QEvent::FileOpen being fired. The strongest (if inconclusive) evidence for this I have is this commit found in a production system, plus a number of blog posts and Google results. So, I first create a new empty QtQuick project. I then write an EventFilter, like this: #include <QtGui> #include <QApplication>

Serialize a class with a Qlist of custom classes as member (using QDataStream)

给你一囗甜甜゛ 提交于 2019-12-13 04:25:06
问题 I'm trying to serialize class Lesson(my custom class[I removed some setters]), which includes a QList(Question is also my custom class). During test serialization I get a SIGSEGV(segmentation fault) when deserializing any object of QList inside the class Lesson. UPD1: I serialized QList* and now I changed it to QList, but SIGSEGV still appears. class Lesson { public: Lesson(); Lesson(QString, QString, QList<Question>); QString getName() const; QString getText() const; QList<Question>* getTest

Nested QVector pointer memory handling

别等时光非礼了梦想. 提交于 2019-12-13 03:51:02
问题 I've inherited a substantial Qt5 project, where the accumulative memory leakage is becoming a serious issue. (Yes, memory leakage should rarely be tolerated but with real life budget and time constraints...). This GUI reads image data into objects of a voxel class, to be displayed graphically. The data comes either from file or buffer (if acquired live) and is stored as a nest qvector, ie: QVector < QVector <Voxel *> > cVoxel; When an image is read from file, cVoxel is initialized using

Qt5 error: ‘ColorKeyMap’ does not name a type

风格不统一 提交于 2019-12-13 03:44:22
问题 I am writing a class which has the following structure: Header File: #pragma once #include <QtCore> #include <QtGui> #include <QtWidgets> class VirtualButton : public QWidget { Q_OBJECT public: VirtualButton( QWidget *parent ); private: static QMap<unsigned int, QColor> ColorKeyMap; static QList<unsigned int> goodKeys; }; CppFile #include "VirtualButton.hpp" QMap<unsigned int, QColor> VirtualButton::ColorKeyMap = QMap<unsigned int, QColor>(); ColorKeyMap[ 23 ] = QColor( 0xff, 0x00, 0xff );