qtquick2

Qt/Qml: Repeater vs. MapItemView for map elements

北城余情 提交于 2019-12-25 10:29:09
问题 I want to populate a Qml Map with map elements (like MapCircle, ...) from a QAbstractListModel . There seem to be two Qml tools suitable for this, MapItemView [1] and Repeater [2]. The Repeater is more powerful (e.g. it allows nested models) - so is there any reason to use the MapItemView instead of a Repeater ? Regards, [1] http://doc.qt.io/qt-5/qml-qtlocation-mapitemview.html [2] http://doc.qt.io/qt-5/qml-qtquick-repeater.html MapItemView source: http://code.qt.io/cgit/qt/qtlocation.git

Constantly repainting a scene of 8000 invisible items, when a MouseArea also exists, causes high CPU usage

守給你的承諾、 提交于 2019-12-25 09:26:05
问题 How to reproduce: Run my code Keep the mouse over the window that appears You'll see that CPU usage is fairly high, although it will depend on your hardware. On my PC it's 20% (5% in each of the 4 virtual cores). My motivation for this testcase: in my real app I have a lot of invisible (culled) items, and while that the culling helps a lot with the CPU usage, it doesn't help as much as I'd expect. I'd like ideas on why the CPU usage is so high, and how to reduce it. My code : main.qml :

pyqt: cannot import QtQuick.Dialogs

与世无争的帅哥 提交于 2019-12-25 08:18:12
问题 I have been trying to use PyQt5 and I have a strange problem where I cannot import QtQuick.Dialogs from a python app. So, consider the following QML file: example.qml import QtQuick 2.0 import QtQuick.Window 2.1 import QtQuick.Layouts 1.1 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.0 // Offending line! import DicomSorter 1.0 ApplicationWindow { id: rootWindow objectName: "window" visible: true width: 800 height: 480 title: "Test" Component

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

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

Accessing Structure inside a structure in QML

白昼怎懂夜的黑 提交于 2019-12-24 20:49:08
问题 Previously I posted a question on how to access structures in QML and got perfect answers from some awesome people and now i need to know is there any way to access structure inside a structure in QML , Following is the code : //MyNewStruct struct MyNewStruct { Q_GADGET float m_range; Q_PROPERTY(float range MEMBER m_range) }; //MyStruct struct MyStruct { Q_GADGET int m_val; QString m_name1; QString m_name2; QString m_name3; QString m_name4; MyNewStruct m_newStr; //**new Struct declaration Q

Text in Custom QQuickItem

人走茶凉 提交于 2019-12-24 18:51:17
问题 I am implementing a Custom QQuickItem which should be able to make a lineplot (x vs y). For performance reasons I did this using QSGNodes. I wonder what is the best way to implement the Text-Labels for the x-ticks (they should get set automatically according to the data range). Should I use a QQuickPaintedItem or is there a way to do it via the QQuickItem? Or is it possible to dynamically create text qml types ( http://doc.qt.io/qt-5/qml-qtquick-text.html) in my c++ file? 回答1: Don't over

Adding a background image to a QQuickItem

旧城冷巷雨未停 提交于 2019-12-24 13:25:42
问题 I have created a QPixmap and drawn smaller QPixmap s on it with QPainter . I want to use the image as the background of a QQuickItem . Is there an easy way to do this? 回答1: If your custom item derived from QQuickItem you can redefine QQuickItem::updatePaintNode() in maybe this way: QSGNode *MyItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) { QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode); if (!node) { node = new QSGSimpleTextureNode();

Click \ flick through emptry area of a Flickable that partially overlaps another Flickable

醉酒当歌 提交于 2019-12-24 11:47:01
问题 I have a scene "editor" flickable on the bottom, and docked at its right side, a scene "outliner" flickable on top of it, which shows a tree of the scene structure. Flickable { id: editor anchors.fill: parent contentWidth: 5000 contentHeight: 5000 Repeater { model: 500 delegate: Rectangle { width: Math.random() * 200 + 50 height: width x: Math.random() * editor.contentWidth y: Math.random() * editor.contentHeight color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1) border.color: