qtquick2

call qmlRegisterType() in the registered class itself

扶醉桌前 提交于 2020-01-07 03:00:30
问题 In my program I have quite a lot of QObject subclasses which are instantiated in QML. Each time I add/remove a new class, I need to add/remove the corresponding call of qmlRegisterType() in main.cpp. I wonder if I can put the call in the code of the registered class itself. This makes it possible to remove a class by removing its cpp/header file and without altering any other C++ code. Also, I can have my main.cpp clean and don't need to include all the header files of the registered classes.

Qt application crashes on exit, OS applies “fault tolerant heap shim”

落花浮王杯 提交于 2020-01-05 10:04:15
问题 I can't isolate what is causing the application to crash on exit. What adds further confusion is that it doesn't always crash, sometimes it does, sometimes it doesn't and it seems to be completely arbitrary. The sample basically crates a custom image provider that loads a static google maps API request as a PNG image to show in QML. The image provider itself works, I first suspected that the issue might be with instantiating the network access manager on the stack, but that's not it, I get

Qt Canvas3D: Calling gl.colorMask or gl.depthMask, even with gl.TRUE for all args, breaks all further rendering

烈酒焚心 提交于 2020-01-05 06:51:28
问题 I've distilled this to a completely trivial testcase. First I setup all low-level stuff like shaders, vertex buffers and matrices. Then I enable all four arguments of gl.colorMask . Then I draw a white triangle. The results is a window that alternates between all black and white (flickers) at a high frequency. I.e. completely buggy. Removing the gl.colorMask call fixes it, and, in my real app, lets all other GL functionality work fine. Side note: the described result is from my minimal

How to Remove a dynamically created item from Column QML Element

依然范特西╮ 提交于 2020-01-05 03:34:10
问题 [EDIT] : I want to remove some controls which are created in Column QML type dynamically and also how to access the children of a layout? .Following is the code which is not dynamic and is just for reference: import QtQuick 2.6 import QtQuick.controls 2.2 Item { Column { id:col spacing: 2 //Initially Adding controls. Rectangle { color: "red"; width: 50; height: 50 } Rectangle { color: "green"; width: 20; height: 50 } Rectangle { color: "blue"; width: 50; height: 20 } } Button { id:button

Set Loader item property

孤街浪徒 提交于 2020-01-04 02:04:09
问题 In the context of a file manager, I have a TableView component saved in the file dirview.qml , which displays the content of some directory using FolderListModel : import QtQuick 2.4 import QtQuick.Controls 1.4 import Qt.labs.folderlistmodel 2.1 TableView { id: tableView property string folder_url: "file:///tmp" anchors.fill: parent TableViewColumn { role: "fileName" title: qsTr("Name") width: tableView.width * 0.7 } TableViewColumn { role: "fileURL" title: qsTr("Size") width: tableView.width

QML doesn't show svg images

半世苍凉 提交于 2020-01-03 15:35:01
问题 I wrote a simple QML ui that is using some svg images. When I execute the app on my desktop everything is fine, the UI is shown and also the svg images on it. The problem happens when I try to execute the app on an embedded device (running windows embedded). In this case the UI is displayed but the svg images are not shown and on the console I'm getting the following message: QML BorderImage: Invalid image data: my_image.svg The png images are shown correctly instead. I research the problem

Better way to reparent visual items in QML

末鹿安然 提交于 2020-01-02 05:46:07
问题 It would seem that in the design of QML user reparent was not really "envisioned", because even though it is possible, it involves creating and changing states, which is just not convenient to add to each and every item. import QtQuick 1.0 Item { width: 200; height: 100 Rectangle { id: redRect width: 100; height: 100 color: "red" } Rectangle { id: blueRect x: redRect.width width: 50; height: 50 color: "blue" states: State { name: "reparented" ParentChange { target: blueRect; parent: redRect;

Inner shadow on QML Rectangle

ぃ、小莉子 提交于 2020-01-02 04:15:07
问题 How do I implement a Rectangle in QML with an inner shadow? See example in link below: Create inner shadow in UIView UPDATE: Here's a simplified version of what I'm trying to do (which does not show any shadow): import QtQuick 2.0 import QtGraphicalEffects 1.0 Item { width: 400 height: 400 Item { anchors.fill: parent Rectangle { id: myRectangle anchors.centerIn: parent width: 200 height: 200 color: "grey" } } InnerShadow { anchors.fill: myRectangle cached: true visible: true horizontalOffset:

Measuring elapsed time in QML

跟風遠走 提交于 2020-01-02 03:40:07
问题 Let's consider the following example: we have a Qt Quick Controls Button . The user clicks it twice within 5 seconds. After pushing the Button for the first time, the QML Timer is running for these 5 seconds. We want to measure the time elapsed between two clicks, with a millisecond accuracy. Unfortunately, the QML Timer can't show us the elapsed time. As suggested on the BlackBerry forums, it would be possible to compare the dates. This isn't very handy, though, since the first click might

HTML formatting in QML Text

99封情书 提交于 2020-01-01 08:47:23
问题 I have a part of HTML code, which displays small table. In browser it looks like in the picture: But when I want to display it in Text QML (which, according to the documentation, should support HTML), I see: (Orange rectangle is a part of rectangle, which is parent of mytext ) Text { id: mytext anchors.fill: parent text: "<div><table border='1'><caption><h4>Test stats</h4>"+ "</caption><tr bgcolor='#9acd32'><th/><th>Number1</th><th>Number2</th></tr> <tr><th>Line1</th>"+ "<td> 0 </td> <td> 1 <