qtquick2

Qt5 & QtQuick2 - transparent main window

♀尐吖头ヾ 提交于 2019-12-20 20:42:09
问题 I am trying to create a simple Qt UI with a frameless window and rounded corners. Starting from a new project with the QtQuick 2 Application template, my code looks like this: main.cpp #include <QtGui/QGuiApplication> #include "qtquick2applicationviewer.h" int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QtQuick2ApplicationViewer viewer; viewer.setMainQmlFile(QStringLiteral("qml/qtquick-test/main.qml")); viewer.setFlags(Qt::FramelessWindowHint); viewer.showExpanded();

How to access the QML object inside the Loader's sourceComponent?

≯℡__Kan透↙ 提交于 2019-12-20 20:29:32
问题 I may need to read or write to some of the properties of the Loader 's sourceComponent from some outside function. What is the way to access the property x of the object inside this Loader 's sourceComponent ? import QtQuick 2.0 Item { width: 200; height: 200 Loader { anchors.fill: parent sourceComponent: rect } Component { id: rect Rectangle { width: 50 height: 50 color: "red" property int x } } } 回答1: When you need to expose an inner object/property to the outside, you should create an

Qt5 Syntax Highlighting in QML

佐手、 提交于 2019-12-20 11:49:50
问题 I am working on a QtQuick 2.0 presentation and I would like to embed some code samples. is it possible easily to create a syntax highlighting qml element. Can you give me example technologies and ideas on how to achieve it. Thanks 回答1: Qt Quick's TextEdit item exposes a textDocument property, of type QQuickTextDocument . This is explicitly exposed so you can use QSyntaxHighlighter directly with the document. QtQuick textEdit documentation for Qt 5.3 回答2: There is no obvious way to achieve

How to package custom controls in QML?

99封情书 提交于 2019-12-20 04:58:10
问题 I would like to create a library of QML custom controls that I would provide to my customers. At the same time I don't want my customers to "reverse-engineer" my controls by peeking into the QML source code. What are my best options to avoid this? The ideal scenario would that I provide my controls as a compiled library that they could import in their own projects. My target platforms are iOS and Android. 回答1: How can I create the package for custom QML controls? These controls should not be

QQuickWidget grab image

巧了我就是萌 提交于 2019-12-20 03:27:30
问题 I am saving an image of a QQuickWidget with several QML children but all I have is a blank image. C++ side: QQuickWidget* content.. content->setSource(QUrl("qml:/main.qml")); QPixmap *pm = content->grab(QRect(QPoint(0,0),QSize(-1,-1)); pm->save("someFilename.png", 0, 100); QML side: Rectangle{ width: 5; height: 5; color: "yellow"; objectname: "rootobj"} In the QML I wish to dynamically add children and be able to show them in the image. I have tried QQuickWindow grabWindow method with a

ListView signals and slots for menu elements

北城以北 提交于 2019-12-20 03:26:09
问题 I'm trying to implement some sort of custom Menu with custom elements. The ultimate goal is to create some sort of popup menu with text and icons. But during creation I faced with some issues. I can show 2 primary problems: There is a strange menu element with title Hello world at the first position (looks like it's read title of application window): From time to time I'm getting errors like qrc:/BreezeQuickMenu.qml:45: TypeError: Property 'clicked' of object QQuickListView(0x1120830) is not

QML: How to reject drop action

帅比萌擦擦* 提交于 2019-12-20 02:14:54
问题 I have one DropArea and two elements. I want DropArea reject the drop event if the DropArea already got one element be dropped, the another element not allow drop into, unless the first one move out. DropArea { property bool dropped: false onDropped: { drop.accepted = !dropped; dropped = true; } onExited: dropped = false } But looks like drop.accepted not work, BTW anyway to get the objects was dropped in DropArea 回答1: You should control if the item must be dropped or not in onReleased ,

How to insert QML view in a QWidget

可紊 提交于 2019-12-19 11:32:22
问题 I am a beginner in QML and try to insert a QML View in QWdiget but I don't understand why it doesn't work. Here is a simple example of my qml file ( this is not the real file ): import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.2 import QtQml.Models 2.1 ObjectModel { id: itemModel Rectangle { color: "orange" anchors.fill: parent } Rectangle { color: "orange" anchors.fill: parent } Rectangle { color: "orange" anchors

How to insert QML view in a QWidget

让人想犯罪 __ 提交于 2019-12-19 11:30:34
问题 I am a beginner in QML and try to insert a QML View in QWdiget but I don't understand why it doesn't work. Here is a simple example of my qml file ( this is not the real file ): import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.2 import QtQml.Models 2.1 ObjectModel { id: itemModel Rectangle { color: "orange" anchors.fill: parent } Rectangle { color: "orange" anchors.fill: parent } Rectangle { color: "orange" anchors

BusyIndicator does not show up

拈花ヽ惹草 提交于 2019-12-19 03:22:53
问题 I want to show a BusyIndicator while a long process is going on. The problem is it does not show up when I make it run and shows afterwards when the process is completed. According to the docs The busy indicator should be used to indicate activity while content is being loaded or the UI is blocked waiting for a resource to become available. I have created a minimal code that based upon the original code Window { id: win width: 300 height: 300 property bool run : false Rectangle { anchors.fill