What can't Qml's DropArea be used? - qt

Qml Source code
import QtQuick 2.0
import QtQuick.Window 2.0
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
DropArea {
anchors.fill: parent
}
}
I use the admin rights to open the program and I can't drag and drop. However, normal opening (normal permissions) can achieve drag and drop.
Why are they doing this, this problem has been bothering me for a long time? How should I solve it.
If you try it, will it be the same?
Environmental:
Qt 5.12.2
Compiler: MSVC 2017 64bit

Related

How to change qml's SystemPalette globally in linux

I'm using systemPalette (Qt5.15) in several qml-based applications in Linux, I need one of these applications to change systemPalette of qml system-wide (globally) so that other applications can detect this change at runtime.
what I need is similar to what happens in KDE, for example, I have the following qml code:
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
SystemPalette {
id: palette
colorGroup: SystemPalette.Active
}
Rectangle{
anchors.centerIn: parent
width: 200
height: width
color: palette.base
}
}
when I run the above code in my KDE plasma, if I change the system's theme from breeze to breeze-dark, the rectangle's color will change at runtime, I can even select a custom color in
Appearance->globalTheme->colors.
In my case, regardless of Linux's distro, my application needs to change systemPalette globally and set its custom values for colors, how can I do that? where does qt read those color values from? (for systemPallete)
Thanks.
P.S: I can create my own style/plugin for qt and set different colors in my custom style, but still I have no idea how to change OS style globally so that all applications can detect this at runtime.

QML indeterminate ProgressBar doesn't animated on Desktop Qt 6.1.2 MSVC2019 64bit Windows 10

It seems that QML indeterminate ProgressBar doesn't animated on Desktop Qt 6.1.2 MSVC2019 64bit Windows 10. The code is showed as followed:
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
ProgressBar {
anchors.centerIn: parent
indeterminate: true
}
}
The result is showed as followed:
And it works fine on Desktop Qt 5.15.2 MSVC2019 64bit Windows 10. The result is showed as followed:

QML Image Element > Retina/HiDPI support for network based images

Image element of the QtQuick supports HiDPI images automatically as you know. For example it can loads #2x images in the iOS and MacOS platforms. Same code works OK on the Android platform.
There is a section in the official documentation that talked about network transparency.
But the Image element doesn't loads HiDPI version images from my server.
Is this a bug?
How can I handle this problem to load high dpi images? Is there any official suggested way?
import QtQuick 2.9
import QtQuick.Window 2.3
import QtQuick.Layouts 1.3
Window {
visible: true
width: 900
height: 520
Image {
id: img
z: 10000
source: "http://127.0.0.1:8080/images/banner-1.jpg" //<-- not loads #2x version automatically
width: 320; height: 205 //<-- also I need to specify a size otherwise it will be so big
}
}
Thank you

CircularGauge parent reference error

when exiting application developed under Qt, I am getting following error:
file:///C:/Qt/5.10.0/mingw53_32/qml/QtQuick/Controls/Private/Control.qml:90:
ReferenceError: parent is not defined
from component defined as simply as this:
import QtQuick 2.8
import QtGraphicalEffects 1.0
import QtQuick.Controls.Styles 1.4
import QtQuick.Extras 1.4
Item {
id:root
CircularGauge {
anchors.centerIn: root
}
}
If line
anchors.centerIn: root
is removed, then there's no error. I am pretty sure that error is produced whenever CircularGauge somehow references parent, although setting
parent:root
in gauge does not help. Any idea what's causing that?
Set anchors.centerIn: parent instead if anchors.centerIn: root.
I was using Desktop Qt 5.10.0 MinGW 32bit. When changed to v5.8, application exits without error and this is enough for me.

Unable to use states with ApplicationWindow

Let's consider this code snippet:
ApplicationWindow
{
/**/
states: State {}
/**/
}
When running the application, I get
Cannot assign to non-existent property "states"
When using
ApplicationWindow
{
/**/
Item { states: State {} }
/**/
}
There is no error. Why can't I use states inside an ApplicationWindow?
I've just realized that ApplicationWindow inherits Window inherits QQuickWindow. Only types which inherit from Item have the states property.
The workaround is to use StateGroup.
Feel free to add a better solution ;)
I was able to code States within an QML ApplicationWindow using Qt v5.11, with two caveats. One was that the Qt Creator v4.6.1 editor flagged SignalTransition with a warning indicating a State cannot have a child item. Despite that warning, the code from the example at http://doc.qt.io/qt-5/qmlstatemachine.html#a-simple-state-machine builds and runs correctly. The second caveat was that the Qt Creator editor ignored the major.minor version of import QtQml.StateMachine. Any numbers I typed in instead of 1.11 were accepted:
import QtQuick 2.11
import QtQuick.Controls 1.4
import QtQml.StateMachine 1.11
ApplicationWindow {
...

Resources