I am running QtCreator with msvc2017_64. Everything was working fine suddenly i am unable to load this simple qml code in QQmlApplicationEngine
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Button {
height: 50
width: 100
anchors.bottom: parent.bottom
text: "close"
//onClicked: closeApp();
}
}
and when i am commenting Button then i can run application. it looks like my QtCreator suddenly stopped support for
import QtQuick.Controls 2.0
Related
I have a problem with changing progress bar color in QML Dial Component. I tried to use Canvas but finally i did nothing. Any suggestions or examples?
Dial {
value: 0.5
anchors.horizontalCenter: parent.horizontalCenter
}
black progress bar
As indicated in this another answer you can use palette, for this you can check the source code, so the solution is:
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.5
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Dial {
// #disable-check M17
palette.dark: "red"
value: .5
anchors.centerIn: parent
}
}
Another way to change the color of an Item is ColorOverlay, which has RGBA support.
https://doc.qt.io/qt-5/qml-qtgraphicaleffects-coloroverlay.html#details
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.5
import QtGraphicalEffects 1.12
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Dial {
id: dial
value: .5
anchors.centerIn: parent
}
ColorOverlay {
anchors.fill: dial
source: dial
color: "#80800000"
}
}
I working on a qt qml application and I want to use the virtual keyboard feature of qt quick. But I want the virtual keyboard to appear only when I touch my laptop screen. The current solution of mine brings virtual keyboard up even when I click mouse on the editable area.
I tried to a lot but couldnt get close to solution. I was thinking of suppressing the mouse click event on the Input Panel but couldnt figure out how
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Layouts 1.1
import QtQuick.VirtualKeyboard 2.1
import QtQuick.Window 2.12
ApplicationWindow {
visible: true
width: 720
height: 480
minimumWidth: 400
minimumHeight:350
TabView {
id:frame
anchors.fill: parent
style: myTabViewStyle
implicitHeight: 100
Tab{
id: setupPage
objectName:"TabParentOfSetup"
enabled: true
title: "Setup"
active: true
SetupTab { }
}
Tab{
id:tabletab
objectName: "TabParentOfTable"
title: "Table"
TableTab{}
}
}
statusBar: StatusBar
{
Label{
id: label
}
}
InputPanel {
id: inputPanel
y: Qt.inputMethod.visible ? parent.height - inputPanel.height :
parent.height
anchors.right: parent.right
anchors.left: parent.left
}
}
I created an empty Qt Quick Application, created a dialog and set the modal to "true", but it's not modal and the dialog disappears when the user clicks outside the dialog
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Component.onCompleted: pickList.open()
Dialog{
id: pickList
modal: true
width: 400
height: 400
}
}
I am trying to use the FileDialog component in QML.
I have done exactly the same code that is in the Qt documentation at the link http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html and it does not show the dialog and returns the error: QFileInfo::absolutePath: Constructed with empty filename. I tried to write a simple code to test it and the return was the same error. My code is below.
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.3
import QtQuick.Dialogs 1.2
Window {
visible: true
width: 360
height: 640
maximumHeight: 640
minimumHeight: 640
maximumWidth: 360
minimumWidth: 360
title: "Acessar Galeria Test"
Rectangle {
id: principal
anchors.fill: parent
FileDialog {
id: fileDialog
title: "Please choose a file"
folder: shortcuts.home
visible: true
}
}
}
Answering my own question:
FileDialog visible property cannot be true while the component is not complete. So the code must be like below:
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.3
import QtQuick.Dialogs 1.2
Window {
visible: true
width: 360
height: 640
maximumHeight: 640
minimumHeight: 640
maximumWidth: 360
minimumWidth: 360
title: "Acessar Galeria Test"
Rectangle {
id: principal
anchors.fill: parent
FileDialog {
id: fileDialog
title: "Please choose a file"
folder: shortcuts.home
visible: false
}
}
Component.onCompleted: {
fileDialog.visible = true;
}
}
I want to access these Properties mentioned here:
http://qt-project.org/doc/qt-5/qml-qtqml-qt.html
application : object
inputMethod : object
platform : object
But I can't find them, the compiler complains about it, I used:
import QtQml 2.2
but nothing changed!
What to do?
Edit:
Here's the code in which I'm trying to use Qt.inputMethod:
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
ApplicationWindow {
id: parentWindow
visible: true
width: 640
height: 480
title: qsTr("Main Window")
TextInput
{
id: text_input1
anchors.fill: parent
font.pixelSize: parent.height-4
text: qsTr("TEXT")
Keys.onReturnPressed:
{
focus = true;
Qt.inputMethod.hide();
}
}
}