qtquick2

Qt accessing model data outside ItemDelegate

我是研究僧i 提交于 2019-12-08 06:08:54
问题 I have some model class that inherits QAbstractListModel : VehiclesModel.h : class VehiclesModel : public QAbstractListModel { Q_OBJECT public: enum Roles { ImagePathRole = Qt::UserRole + 1, // QString NameRole // QString }; virtual int rowCount(const QModelIndex & parent = QModelIndex()) const override { ... } virtual QVariant data(const QModelIndex & index, int role) const override { ... } virtual QHash<int, QByteArray> roleNames() const override { QHash<int, QByteArray> roles =

Why Qt signal will not work after use class as property in qml page?

ⅰ亾dé卋堺 提交于 2019-12-08 06:06:59
问题 I have a c++ class like below and i used this class after registering that in an qml page and that signals works well in qml page class1.cpp QString Class1::message(){ return m_Message; } void Class1::setMessage(QString m){ m_Message=m ; emit messageChanged(); } void Class1::invokeEvent(){ setMessage("The Second Message"); } Class2* Class1::getClass2Obj(){ class2obj.plusplusClickCount(); return &class2obj; } class1.h class Class1 : public QObject { Q_OBJECT QString m_Message; Class2 class2obj

Custom source property for VideoOutput QML

ε祈祈猫儿з 提交于 2019-12-08 04:05:29
问题 What exactly has to be done to provide custom source of frames for VideoOutput QML object? Does VideoOuput itself provide an instance of QAbstractVideoSurface class to the "source"? The Qt5 documentations says following thing about providing about this issue: If you are extending your own C++ classes to interoperate with VideoOutput, you can either provide a QObject based class with a mediaObject property that exposes a QMediaObject derived class that has a QVideoRendererControl available, or

Items not correctly spread across GridLayout

亡梦爱人 提交于 2019-12-08 02:35:59
问题 I have the following custom QML Item , which will represent a pin code entry GUI element: import QtQuick 2.0 import QtQuick.Layouts 1.2 import QtQuick.Controls 1.3 import "../items" Item { id: ueKeypad width: 512 height: 512 Rectangle { id: ueKeypadWrapper antialiasing: true anchors.fill: parent ColumnLayout { id: ueKeypadLayoutMain antialiasing: true layoutDirection: Qt.LeftToRight spacing: 8 anchors.fill: parent ColumnLayout { id: ueKeypadTitleLayout layoutDirection: Qt.LeftToRight Layout

How to cache complex item into texture and release the memory for the actual complex item?

谁都会走 提交于 2019-12-07 19:38:26
I've got a big number of items that are quite complex (memory-heavy), and in order to fit in limited RAM, I want to cache some of them into textures and not keep the actual complex item in memory. In particular, items for which I want to do that are all those (among my complex items) that do not currently need to animate (and this means most of them). For the purposes of this question I call this kind of items "inactive". My plan was: When an item "foo" becomes inactive: Create dynamically a ShaderEffectSource (with no associated ShaderEffect ) with live: false; source: foo , in the same

Why Qt signal will not work after use class as property in qml page?

谁说我不能喝 提交于 2019-12-07 17:44:32
I have a c++ class like below and i used this class after registering that in an qml page and that signals works well in qml page class1.cpp QString Class1::message(){ return m_Message; } void Class1::setMessage(QString m){ m_Message=m ; emit messageChanged(); } void Class1::invokeEvent(){ setMessage("The Second Message"); } Class2* Class1::getClass2Obj(){ class2obj.plusplusClickCount(); return &class2obj; } class1.h class Class1 : public QObject { Q_OBJECT QString m_Message; Class2 class2obj; public: explicit Class1(QObject *parent = nullptr); Q_PROPERTY(QString message READ message WRITE

Appending object with Javascript array to a QML ListModel causes SEGFAULT

試著忘記壹切 提交于 2019-12-07 16:41:00
问题 I am using QtQuick on Android. I am trying to append a Javascript object with an array property to a ListModel . I use LocalStorage to store this data. The object I materialise from the database has this array property, and when I try and append that object to the ListModel I get a SEGFAULT. If I do not include an array in my object, or in fact if the array is empty, then it will successfully append to the ListModel and will not SEGFAULT. When I materialise the object from the database, I do

How to stop window size jumping around when forcing fixed aspect ratio?

随声附和 提交于 2019-12-07 15:59:34
Here's my test code: import QtQuick 2.4 import QtQuick.Window 2.2 Window { visible: true readonly property int defaultWidth: 700 readonly property int defaultHeight: 500 width: defaultWidth height: defaultHeight readonly property real aspectRatio: defaultWidth / defaultHeight readonly property real scaleFactor: width / defaultWidth onWidthChanged: { var properHeight = Math.round(width / aspectRatio); if ( height !== properHeight ) { height = properHeight } } onHeightChanged: { var properWidth = Math.round(height * aspectRatio); if ( width !== properWidth ) { width = properWidth } } TextEdit {

How GUI screen transition works in qml

匆匆过客 提交于 2019-12-07 15:50:00
问题 I'm a C++ developer, now studying about GUI development using QML in QtQuick. In GUI creation, only one screen is visible to the user. And based on user interaction, the screens are switched. But what actually happens behind? There are lot of info only on how to design a single screen, but very less resource for how to manage the transitions of their states. Are all the screens and components loaded when starting the application and change the layer order to display once screen, OR after an

Qt accessing model data outside ItemDelegate

旧城冷巷雨未停 提交于 2019-12-07 15:08:34
I have some model class that inherits QAbstractListModel : VehiclesModel.h : class VehiclesModel : public QAbstractListModel { Q_OBJECT public: enum Roles { ImagePathRole = Qt::UserRole + 1, // QString NameRole // QString }; virtual int rowCount(const QModelIndex & parent = QModelIndex()) const override { ... } virtual QVariant data(const QModelIndex & index, int role) const override { ... } virtual QHash<int, QByteArray> roleNames() const override { QHash<int, QByteArray> roles = QAbstractListModel::roleNames(); roles[ImagePathRole] = "imagePath"; roles[NameRole] = "name"; return roles; } };