qtquick2

How to make a transparent window with Qt Quick 2.0

喜你入骨 提交于 2019-12-05 13:06:08
I've already know how to make a transparent window with Qt Quick 1.0.But I started to use Qt 5.0 and Qt Quick 2.0 recently and didn't know how to do with it. setAttribute setWindowFlags setStyleSheet The functions above are removed from the QtQuick2ApplicationViewer(QQuickView). So I wonder whether I can make a transparent window with Qt Quick 2 or not (is it because that it's based on OpenGL?). Look here for a possible solution: http://code.google.com/p/quickwidget/ But, with Qt 5.3 , it is possible to use the built-in QQuickWidget class. Here's a Qt5 code: QSurfaceFormat surfaceFormat;

How to set currentIndex of SwipeView to currentIndex of TabBar “by reference” after going to specific page?

早过忘川 提交于 2019-12-05 11:05:07
I'm getting started with QtQuick Controls 2.0. I have experience with C++ and a small amount of experience with Qt, but I have not worked with QML before. I have a TabBar and a SwipeView that are linked to each other. What I mean by this is that when you select a page on the TabBar , the SwipeView goes to that page. When you swipe to a page from the SwipeView , the TabBar updates itself to reflect that. As a learning exercise, I decided to create a button that would send the user to the second page. The issue is that I can't seem to find a way to do so without messing up the link between the

Q_ENUMS are “undefined” in QML?

跟風遠走 提交于 2019-12-05 08:26:36
Enums are not working out for me. I have registered them with Q_ENUMS() I did not forget the Q_OBJECT macro the type is registered using qmlRegisterType() the module is imported in QML In short, everything is "by-the-book" but for some reason I continue getting undefined for each and every enum in QML. Am I missing something? class UI : public QQuickItem { Q_OBJECT Q_ENUMS(ObjectType) public: enum ObjectType { _Root = 0, _Block }; ... }; ... qmlRegisterType<UI>("Nodes", 1, 0, "UI"); ... import Nodes 1.0 ... console.log(UI._Root) // undefined EDIT: Also note that the registered enums are indeed

Measuring elapsed time in QML

拥有回忆 提交于 2019-12-05 06:42:50
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 occur on 31 Dec 2015, 23:59:55 and the second on 1 Jan 2016, 00:00:05 and the check would have to be

Change text color for QML controls

↘锁芯ラ 提交于 2019-12-05 05:46:25
I am using some QML controls like GroupBox and CheckBox which have text associated with them. The default color of the text is black. However, I have these items on a dark background and would prefer using white for the text color. These items don't have a color property so I'm not sure what to do. CheckBox { text: "Check Me" } koopajah You need to use the style property to redefine the Component to use for the label based on the CheckBoxStyle import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 Rectangle { color: "black" CheckBox { style: CheckBoxStyle { label:

System tray icon without widgets

China☆狼群 提交于 2019-12-05 05:43:42
I'm wondering if there's a way to implement system tray icon + menu functionality without widgets module? jpnurmi Qt 5.8 introduces a SystemTrayIcon QML type in the experimental Qt Labs Platform module, as part of the Qt Quick Controls 2 offering. It uses a native implementation directly from the Qt Platform Abstraction layer where available, and Qt Widgets as a fallback on other platforms. 来源: https://stackoverflow.com/questions/41095630/system-tray-icon-without-widgets

How to find QML item by its string id?

醉酒当歌 提交于 2019-12-05 05:20:46
I have a string id of an object I need to find in QML tree. For example: var idToFind = "myBtnId" Can I do something like the following? var objectThatINeed = myMainWindow.findObjectById(idToFind) As far as I understand I can use objectName for this purpose (at least from C++). Can I still reuse existing id s somehow without introducing the names? I want to use this object as a parent for some other dynamically created controls. No, you have to use objectName or some other property. The id Attribute : Once an object instance is created, the value of its id attribute cannot be changed. While it

QML screen orientation lock

落花浮王杯 提交于 2019-12-05 03:47:57
I need to lock the screen to a specific orientation for an android app that I'm making. is there a way to do that in QML? Google didn't get me any answers. I am using Qt 5.2. You can basically use the Screen.orientation property for reading only. See the following example for details: http://qt-project.org/doc/qt-5/qtquick-window-screeninfo-qml.html The proper way as of today is to use the Android manifest file for this as done by the Qt Android developer at Digia for his QtHangMan game which is: <activity android:screenOrientation="portrait" ... Arun The way to do this is- Create an out-of

FileDialog in QTQuick (QML): Save file under given name

折月煮酒 提交于 2019-12-05 03:30:44
We're building a Qt Quick app, that must be able to save a file under a given name . In the FileDialog component you can only set a directory. This is not very user-friendly, since you don't want to type in a filename by hand every time you download a file. So far we tried different things FileDialog from QtQuick.Dialogs: filename cannot be set Native dialog via QPlatformFileDialogHelper (naughty private c++ hack): filename cannot be set on Linux (Gnome) Native dialog via static QFileDialog::getSaveFileName(): in Quick application there is no QWidget available for 'parent' QT dialog via

Are “var” and “variant” the same thing?

大憨熊 提交于 2019-12-05 01:28:05
From what I understand, to make a property an array in QML you must specify it as the type variant or var : property var myArray:[] And this appears to be exactly the same as: property variant myArray:[] Is this true? Tim Meyer According to the Qt 5.0 variant documentation : The variant type is a generic property type. It is obsolete and exists only to support old applications; new applications should use var type properties instead. So yes, it is the same, but you should always stick to var (unless you got an earlier version which does not support that yet). This is not a completely new