qtquickcontrols2

FileDialog in Qml not working in Release

ⅰ亾dé卋堺 提交于 2021-02-19 06:16:29
问题 I am working on project with Qt Quick Control 2 . When I try to run my software in debug mode FileDialog.qml opens perfectly but when I deploy it as release mode it doesn't work. Here is my code: import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Controls 1.3 import QtQuick.Dialogs 1.0 // File Dialog to browse FileDialog { id: openDialog title: "Please Select An Image" folder: shortcuts.pictures nameFilters: ["Image files (*.BMP)"] modality: Qt.NonModal selectExisting: true /* * do

How to center dialog on screen in QtQuick Controls 2?

此生再无相见时 提交于 2021-01-02 05:31:35
问题 All my dialogs appear on the top left corner of screen instead of the center. What is the best way to let the dialogs be placed automatically correct? import QtQuick 2.7 import QtQuick.Controls 2.2 ApplicationWindow { id: mainWindow visible: true width: 640 height: 480 title: qsTr("Hello World") Component.onCompleted: { showMessageBox('Hey this actually works!'); } function showMessageBox(message) { var component = Qt.createComponent("MessageDialog.qml") if(component.status == Component.Ready

QML - Cannot assign to non-existent property “style”

独自空忆成欢 提交于 2020-07-18 09:07:54
问题 I'm using Qt 5.10.1 with Qt Creator 4.5.1 and the style property is never available in elements. For example, as shown here ButtonStyle QML Type , I would like to do: Button { text: "A button" style: ButtonStyle {...} } But, I get the error: Cannot assign to non-existent property "style" I tried with a rectangle, progressbar and I get the same error. Edit #1: I do have all these imports. If the import was missing, I would get the error on ButtonStyle , but the error is on style . import

Quick Controls 2 bad looking

浪尽此生 提交于 2020-01-06 07:07:50
问题 Qt 5.10, Windows 10 desktop. The following QML code: import QtQuick 2.10 import QtQuick.Window 2.10 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 Window { visible: true width: 250 height: 100 title: qsTr("My app") GridLayout { columns: 2 Label { text: "Setting1:" } ComboBox { model: ["100%", "90%", "80%", "70%", "60%", "50%", "40%", "30%"] } CheckBox { id: tidle text: "Setting2:" } ComboBox { model: ["90%", "80%", "70%", "60%", "50%", "40%", "30%"] enabled: tidle.checked } } } gives

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

how to access properties of item inside loader object

て烟熏妆下的殇ゞ 提交于 2019-12-25 09:27:35
问题 I am using a qml Loader component to push a page dynamically into view. Now the page I push has various properties and I would like to access them from the Loader component itself. However, I am unable to create aliases to these properties. So, I have something like: Loader { id: loginLoader source: "qrc:/pages/IdPinLoginPage.qml" property alias hasNavBar: loginLoader.item.hasNavBar property alias hasStatusBar: loginLoader.item.hasStatusBar } This results in Invalid alias target location .

how to create a scrollbar for rectangle in QML

为君一笑 提交于 2019-12-24 00:43:34
问题 like the web pages,when content's high beyond the rectangle,there is a scrollbar. Is there anyone else who can help me? I have tried with listview,but I can't use it in a rectangle 回答1: There is an example in the docs, how to use ScrollBar without a Flickable: import QtQuick 2.7 import QtQuick.Controls 2.0 Rectangle { id: frame clip: true width: 160 height: 160 border.color: "black" anchors.centerIn: parent Text { id: content text: "ABC" font.pixelSize: 160 x: -hbar.position * width y: -vbar

QtQuick.Controls 2 StackView and destroyOnPop

我们两清 提交于 2019-12-24 00:25:16
问题 I have application which uses StackView and pushes a lot of dynamic created objects into this StackView and I need some way to destroy this objecst when they are popped from StackView. If I use Controls 1 Stackview, I can just push object with destroyOnPop property (like it was shown in this question): tablesStack.push({item: view, destroyOnPop: true}) but it doesn't applicable to Controls 2 StackView. What is correct solution of this problem? I know only one way: call object.destroy() with

StackView alternative in QML

匆匆过客 提交于 2019-12-23 02:34:40
问题 I was using till now a StackView in QML to go from one screen to the other. But I figured out it is also possible to just create different items that would be set to visible or not visible to update the screen with a new view. I could have for example a header, a main item (Item1) set to visible and a footer. I could then set Item1 to not visible and Item2 to visible. I was wondering what is the advantage/disadvantage of each solution? (StackView VS views visible/invisible) 回答1: As @ddriver

How do I apply the style to a TextField in QML? It seems “style” attribute isn't available

╄→гoц情女王★ 提交于 2019-12-17 16:47:14
问题 I am trying to apply some styles to a new qt 5.7 application I am working on and the following is not working at all. It gives the error: qrc:/SignInView.qml:67 Cannot assign to non-existent property "style" And I can't edit it in design mode for the same reasons. import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.4 Page { id: page1 ColumnLayout { id: columnLayout1 height: 100 anchors.right: parent.right anchors.left: parent.left anchors