qml

GC crashes QML-Application

泄露秘密 提交于 2019-12-25 07:59:54
问题 Do not fear! This is not production code. It is just to learn new things about QML! I do not seek 'you shall not do something like this - do it like that.' I am more interested in the internals of QML Consider the following QML-Code import QtQuick 2.4 import QtQuick.Window 2.0 Window { id: root width: 800 height: 600 visible: true GridView { width: 800 height: 200 model: 4000 flow: GridView.FlowTopToBottom delegate: Rectangle { id: myDelegate width: 100 height: 100 border.width: 1 Column {

ListView exceeding parent area [duplicate]

爷,独闯天下 提交于 2019-12-25 07:59:49
问题 This question already has an answer here : Hide the highlight of a ListView while scrolling (1 answer) Closed 3 years ago . I'm using ListView and I'm loading that onto a Rectangle . While scrolling the content up or down the content is not correctly hidden and remains visible to the user. Can someone help me on this issue? 回答1: As reported by the documentation: Note: Views do not enable clip automatically . If the view is not clipped by another item or the screen, it will be necessary to set

module [] is not installed — registering custom C++ wrapper for QML

一笑奈何 提交于 2019-12-25 07:17:51
问题 I need to access a C++ API to work with CAN bus. Looks like the best solution is to write a QML wrapper to expose all the functionality I need. Here is my canservice.cpp so far: #include "canservice.h" #include <QCanBus> #include <QDebug> #include <QCanBusFrame> #include <QTimer> #include <QtCore/qbytearray.h> #include <QtCore/qvariant.h> #include <QtCore/qdebug.h> CANService::CANService(QObject *parent) : QObject(parent), m_canDevice(nullptr) { QString status = ""; initializeSettings(); //

How to create a custom grouping of properties and apply them to different controls?

ぃ、小莉子 提交于 2019-12-25 06:56:37
问题 I have a window with Buttons, TextFields, Labels etc. These all share common properties like font family, color, size etc. What I would like to be able to do is to define a grouping of these properties (called, say, textStyles.MainTitle or textStyles.DescriptiveText etc.) that would include a font family, size and weight, height and color. And then in the QML file I would write something like: myCustomProperty: textStyles.MainTitle and this would apply those values to the control. How can I

Refresh QML Listview from Slot

a 夏天 提交于 2019-12-25 04:27:32
问题 I have problem with the refreshing Listview in QML I looked through many solutions but there is nothing concrete i want from event "onClicked" refresh all listview but how to do this? sourcecode: http://s000.tinyupload.com/?file_id=86538244635919176055 main.cpp #include <QApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include <QDebug> #include "message.h" #include "dataobject.h" int main(int argc, char *argv[]) { QList<QObject*> dataList; dataList.append(new DataObject(

Set GridView model property from C++ without setting Context

断了今生、忘了曾经 提交于 2019-12-25 04:27:18
问题 I'm trying to set the model property of a QML GridView from C++ by calling QQmlProperty::write(gridview, "model", QVariant::fromValue(objlist)); . gridview is set correctly, I can modify the property from C++, when I set it to a QList with 6 entries and print them from QML I get qml: model = item(0x30617b50), Item(0x30617b90), Item(0x30617bd0), Item(0x30617c10), Item(0x30617c50), Item(0x30617cd0) , though the model is not being displayed. The Qt documentation suggest calling QQmlContext *ctxt

Share Invoke is sometimes blank

浪尽此生 提交于 2019-12-25 04:22:34
问题 I have a strange bug using a share invoke. About 1 in 3 attempts to share will result in no text being shared. Usually the first share will work but further attempts will not work. Randomly it will start working again. This happens with bbm, facebook and twitter apps. The following code is part of a listview listitem. InvokeActionItem { id: invokeActionItem title: "Share" ActionBar.placement: ActionBarPlacement.OnBar imageSource: "asset:///Images/Icons/share_icon.png" query { mimeType: "text

How to avoid repetitive code in QML?

99封情书 提交于 2019-12-25 03:44:13
问题 I'm using Qt 5.4.1. I'm currently setting up some buttons in QML. I want similar state behaviours for some of the buttons - how to do I avoid having large chunks of very similar code repeated through the QML? Rectangle { id: songFilterButton x: 0; width: 80 y: 0; height: 60 Text { anchors.centerIn: parent text: "Songs" } state: "on"; states: [ State { name: "on" PropertyChanges{ target: songFilterButton; color: "steelblue" } }, State { name: "on" PropertyChanges{ target: songFilterButton;

Running into issues with QVariantLists and QLists of custom QObjects

◇◆丶佛笑我妖孽 提交于 2019-12-25 03:37:25
问题 I'm hoping to get some help with a snag I've run into on a personal project. Essentially I have a custom QObject inheritor that contains its own various elements of data, and another custom QObject that I would like to have some collection element of multiple instances of the other custom QObject. I've tried various ways of implementing this and thus far I've had no real success, the closest being with a QVariantList. The following snippets are from an example I wrote to recreate the issue,

How to add text in plotting area of chartview in qml

倖福魔咒の 提交于 2019-12-25 02:52:19
问题 How do I place text at specific (x,y) locations within the plotting area of a QML ChartView type? For example, I would like to place text at the location XYPoint{x: -3; Y: 20} I don't want to place at window's(x,y), i want to put at plotting area's (x,y) I read documentation,but i don't find any property !!!!!! //ChartView for plotting points ChartView{ id:chrt anchors.fill: parent height: parent.height width: parent.width legend.visible: false backgroundColor: "black" //X- axis ValueAxis{ id