qtquick2

QtQuick animation freezing on list and open serial ports

旧时模样 提交于 2019-12-06 15:25:14
问题 I wrote a C++ method to find all serial ports, open, write and close and use to Q_INVOKABLE to call this method from a QML. At QML, first I push a LoadingPage.qml to StackView and then I call the find() Serial Ports, inside the onClicked: Button slot. The problem: It is a freezing on push a LoadingPage.qml to StackView if there are many serial ports connected, the animation start and then immediately freezes, when the function find finish the animation start again. [SerialPort.qml] How is it

MapItemView is not updated after a dataChanged signal

烈酒焚心 提交于 2019-12-06 14:24:47
I am using the QML MapItemView component with a C++ QAbstractListModel -based model. The MapItemView is working fine when the model is reset, or whenever a new item is added or an existing item is removed. However, the MapItemView is not reflecting changes to already added items. I have first experienced this issue with Qt 5.4 but I still face it after updating to Qt 5.5 The following example shows the issue with 2 different models : a C++ model based on QAbstractListModel and a QML ListModel . It is possible to switch from one model to another, pressing the top-right button: When the QML

QML TreeView not updating at runtime after adding new data to the model

放肆的年华 提交于 2019-12-06 13:53:48
问题 I have a QML TreeView that gets data through a QStandardItemModel . When the application is running, I press a button which adds a new entry. I know the data is changing, but the QML TreeView is not updating. I've also tried beginResetModel() and endResetModel() . The data is correctly displayed in the TreeView upon loading the application, but the TreeView does not change when modifying the data in the model. treeviewmodel.cpp #include <QDebug> #include <QStandardItemModel> #include

How to implement rich text logic on QML TextEdit with QSyntaxHighlighter class in Qt?

柔情痞子 提交于 2019-12-06 12:07:45
I have a TextEdit in my QML file and I have a QSyntaxHighlighter C++ class. I want to specify the highlighting logic in the C++ class and apply it to the TextEdit, but I am not sure how to make the connection between the QML object and the C++ class. Can you also please provide some sample code? I couldn't find how to implement it with the Qt documentation. You can use TextEdit::textDocument , which holds an instance of QQuickTextDocument , to gain access to the underlying QTextDocument that you can pass to QSyntaxHighlighter constructor. In case someone needs a more detailed explanation for

QtQuick dynamic object in a different context

為{幸葍}努か 提交于 2019-12-06 11:53:32
In my qml I'm creating a C++ component object but can't figure out how to reference the object once it's created. Here's the qml to create an OgreScene object: MouseArea { anchors.fill: parent function scene() { var scene = Qt.createQmlObject( "import Client.Plugin.Ogre 0.1; OgreScene{ id: pluginScene; engine: OgreEngine }", plugin ); console.log( "qml: init scene" ); pluginScene.init(); } onClicked: scene() } When I run it I get: Qt Debug: qml: init scene Qt Warning: qrc:///client.qml:118: ReferenceError: pluginScene is not defined I added this to the inline qml: import Client.Plugin.Ogre 0.1

HelloWorld Deployment with QtQuick 2.0 in Windows 7 and XP

只愿长相守 提交于 2019-12-06 11:51:07
问题 I've been struggling to get my application deployed properly for several weeks now (it's a hobby), and I just don't know what else to try. I started a new project in Qt Creator (2.6.1), by selecting Applications -> Qt Quick 2 Application (Built-in Elements). I tweaked the QML to make the background blue and text red: main.qml import QtQuick 2.0 Rectangle { width: 360 height: 360 color: "blue" // Added! Text { text: qsTr("Hello World") anchors.centerIn: parent color: "red" // Added! }

Custom listModel does not notify the view

梦想与她 提交于 2019-12-06 09:51:43
I have my custom list model where I put data which should be displayed on the QML view. But for some kind of reason the view in QML sometimes is updated normally, sometimes with previous data and sometimes updating is not performed. Here is the function where I fill the model - this function is called from some other thread. void MyScreen::fillListModel() { const QString SEPARATOR = " "; myListModel->resetModel(); for (int i = 0; i < MAX_ROWS; ++i) { QString key = QString::fromUtf16(MyData::getParameterKey(i).c_str()); QString val = QString::fromUtf16(MyData::getParameterVal(i).c_str());

Items not correctly spread across GridLayout

扶醉桌前 提交于 2019-12-06 09:26:58
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.fillWidth: true Layout.minimumHeight: 24 Layout.preferredHeight: 24 Layout.maximumHeight: 24 Text {

OpenGL and QtQuick Texture Problems

我的梦境 提交于 2019-12-06 08:06:19
问题 I'm developing a simple QQuickItem implementation in C++ based on the "openglunderqml" example that came with Qt. I made some modifications to use different shaders and two textures that I load in. The idea is that the shaders will crossfade between the two textures (which are essentially just images I have loaded into the textures). When I put this QQuickItem alone inside a QML file and run it, everything works fine. The images crossfade between each other (I've setup a property animation to

Custom TextEdit, how to hide TextInput when it goes wide

放肆的年华 提交于 2019-12-06 05:36:15
I've trying to create custom text field using TextInput element (I need it to use validator and custom style). But I can't hide part of TextInput content expanding (see image). I have similar problem with other elements, while it have root item (container) what contains other items, childrens can be seen if they are placed out of container coordinates. How can I make childrens parts hidden if they're out of root container? There is the code, but it's actually just template, I've tried to uze z attribute, with no success. BreezeQuickLineInput.qml import QtQuick 2.4 Item { id: root property int