Qt seems to take only Mouse Events instead of touch screen, VirtualKeyboard Issue - qt

I'm using debian 11, with a Xorg server running and Qt5.15.2 installed.
Very basic question that I don't know how to tackle: let's say we have a simple QML file with a InputPanel and a Textfield:
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.VirtualKeyboard 2.15
import QtQuick.Controls 1.4
Window {
id: window
width: Screen.width
height: Screen.height
visible: true
title: qsTr("Hello World")
InputPanel {
id: inputPanel
z: 99
x: 0
y: window.height
width: window.width
states: State {
name: "visible"
when: inputPanel.active
PropertyChanges {
target: inputPanel
y: window.height - inputPanel.height
}
}
transitions: Transition {
from: ""
to: "visible"
reversible: true
ParallelAnimation {
NumberAnimation {
properties: "y"
duration: 250
easing.type: Easing.InOutQuad
}
}
}
}
TextField {
placeholderText: qsTr("Enter name")
}
}
I've already done in the main.cpp :
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
And already inserted this line in the .pro file of my project:
QT += quick virtualkeyboard
The issue I found is: VirtualKeyboard does not type anything if I use the touch screen (it correctly appears but no key is prompted and warning "input method is not set" is raised), untill I click with my USB mouse. Then everything is fine, the virtual keyboard prompts and all is fine.
My question is: why? Is it something with X11, debian or something else(like xinput?)?
I tried some configuration of the Xserver for input handling, and adding focus to some QML elements but none works

Related

Qt Virtual Keyboard only shows a black rectangle when lauching InputPanel

I am using Qt 5.12 and QtQuick.VirtualKeyboard 2.3 to develop an application on an embedded device. The problem is:
When I click the input field to enter something, only the inputpanel pops up, but there are no keys on the inputpanel. So the screen only shows a black rectangle for the virtual keyboard(As shown in the picture). I am pretty sure the black rectangle is the inputpanel. Because if I change the size of InputPanel in my code, the size of this black rectangle will also change.
I am wondering if anyone has met this problem before. What are the possible reasons for this issue? Are there any methods to display keys on inputPanel? Thanks!
This is image for the black rectangle shown on screen
This is the code for InputPanel:
InputPanel {
id: inputPanel
z: 99
x: 0
y: root.height
width: root.width*2.1
states: State {
name: "visible"
when: inputPanel.active
PropertyChanges {
target: inputPanel
y: root.height - inputPanel.height
}
}
transitions: Transition {
from: ""
to: "visible"
reversible: true
ParallelAnimation {
NumberAnimation {
properties: "y"
duration: 250
easing.type: Easing.InOutQuad
}
}
}
}
}
This is the first line of my main.cpp file:
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
And this is the configurations in .pro file:
static {
QT += svg
QTPLUGIN += qtvirtualkeyboardplugin
}
CONFIG += disable-desktop

Incompatible MapboxGL plugin built on MSVC2019 with QtQuick

I built Mapbox GL Native on MSCV 2019 successfully based on #dpaulat implementation.
https://github.com/mapbox/mapbox-gl-native/pull/16611
and, generated mapboxgl plugin for Qt5.15.2
I tested on a very simple project, map can be loaded but the text inside the rectangle is invisible. (If I put text into "Item", the text is visible)
Does it seem the mapboxgl plugin impact qt quick ???
The text inside the rectangle disappears
Main.qml file:
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtLocation 5.15
ApplicationWindow {
width: 800
height: 600
visible: true
Rectangle{
id: rectId
width: 400
height: 100
color: "yellow"
Text {
id: textInsideRect
anchors.centerIn: parent
text: qsTr("R E C T")
font.pixelSize: 20
color: "red"
}
}
Item {
id: itemId
x: 400
width: 400
height: 100
Text {
id: txtItem
text: qsTr("I T E M")
anchors.centerIn: parent
font.pixelSize: 20
color: "red"
}
}
Map {
id: map
y: 100
width: 800
height: 500
plugin: Plugin {
name: "mapboxgl"
PluginParameter {
name: "mapboxgl.access_token";
value: "pk.eyJ1IjoidGFudHJpZG8iLCJhIjoiY2tlYnB0YWo0MGFpczJzcnZubHRlNTAwbiJ9.6QG-4BeuCpUjaawDiyyfVg"
}
PluginParameter {
name: "mapboxgl.mapping.additional_style_urls";
value: "mapbox://styles/tantrido/ckyuch3ub001q16ofjwsxnlz6"
}
}
}
}
The mapboxgl plugin Qt 5.15.2 :
https://github.com/MyLV1701/MapboxGL_Dll/tree/main/MapboxGL_VS2019_Qt5152_maplibre-gl-native
※ Just to put the *.dll file into "msvc2019_64\plugins\geoservices" folder.
In my case, "C:\Qt\5.15.2\msvc2019_64\plugins\geoservices"
and, also the same issue when I built mapboxGL plugin based on maplibre-gl-native.
https://bugreports.qt.io/browse/QTBUG-74463
Is this a good idea for solving this problem?
Sorry for my bad English.

QML animation - moving the application window

I want to create an animation to move (or resize) my application Window built using QML.
I have the following code (most of it created by default when we create a QT quick Controls application:
main.cpp
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
MainForm.ui.qml
import QtQuick 2.6
import QtQuick.Controls 1.5
import QtQuick.Layouts 1.3
Item {
width: 640
height: 480
property alias button1: button1
property alias button2: button2
RowLayout {
anchors.centerIn: parent
Button {
id: button1
text: qsTr("Press Me 1")
}
Button {
id: button2
text: qsTr("Press Me 2")
}
}
}
main.qml
import QtQuick 2.6
import QtQuick.Controls 1.5
import QtQuick.Dialogs 1.2
ApplicationWindow {
id: mainWindow
visible: true
width: 640
height: 480
title: qsTr("Hello World")
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
MainForm {
anchors.fill: parent
button1.onClicked: Qt.quit();
button2.onClicked: state = "other";
}
transitions: [
Transition {
from: "*"
to: "other"
NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 }
}
]
states: [
State {
name: "other"
PropertyChanges {
target: mainWindow
x: x + 200
}
}
]
MessageDialog {
id: messageDialog
function show(caption) {
messageDialog.text = caption;
messageDialog.open();
}
}
}
With this code, I was simply trying to move my window 200 pixels to the right. When I try to run it, I get qrc:/main.qml:42 Cannot assign to non-existent property "states". I believe that is weird, because when I start typing "states" and choose to auto-complete, it builds to me the whole structure, so I thought it should exist...
I'm new to QML, and I'm not fully familiar with the several options of animations that exists. This one I've tried based on the example that comes with QT creator (animation.pro - code from transitions).
I believe it should be quite simple, right? Could you help me with this?
Qt Creator has a feature where you can insert code snippets using certain keywords. You can see which snippets are available by going to Tools > Options > Text Editor > Snippets.
Snippets will show up as red in the auto completion popup, and regular properties (or types, as is the case below) will show up as green:
So, ApplicationWindow doesn't have a states property. If you're ever in doubt, go to the documentation for the type you're interested in (e.g. http://doc.qt.io/qt-5/qml-qtquick-controls-applicationwindow.html) and click on the link that says "List of all members, including inherited members". This will show you all properties, functions, etc. belonging
to that type.
If you want to animate the window's position, you can use a NumberAnimation without using states:
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 1.5
ApplicationWindow {
id: window
width: 400
height: 400
visible: true
NumberAnimation {
id: xyAnimation
target: window
properties: "x,y"
easing.type: Easing.InOutQuad
duration: 2000
to: 500
}
Button {
text: "Start"
onClicked: xyAnimation.start()
}
}
state is a property in Item, however ApplicationWindow is not an Item. To add state/transition to an non-Item type, use StateGroup:
ApplicationWindow {
id: mainWindow
//your code...
MainForm {
button2.onClicked: { myWindowStates.state = "other";}
}
StateGroup {
id: myWindowStates
transitions: [
Transition {
from: "*"; to: "other"
NumberAnimation {
properties: "x,y"; easing.type: Easing.Linear;
duration: 2000
}
}
]
states: [
State {
name: "other"
PropertyChanges {
target: mainWindow
x: mainWindow.x + 200
explicit: true //Remember to set this
}
}
]
}
}
Remember to set PropertyChange.explict to true, otherwise the state behavior is wrong and your window will disappear after the transition finished.

How to use QML Connect{} with Qt Creator Design Mode

The below code works fine in Qt Creator Edit Mode, but when I try to switch to Design Mode it gives an error:
"Can not open this qml document because of an error in the qml file."
And then I can't edit the layout graphically. If I comment out the Connect{} item then Design Mode works again and I can edit graphically.
Anybody see what the error might be.
What am I doin wrong? Thanks for looking.
import QtQuick 2.4
import QtQuick.Window 2.2
Window {
id: window1
visible: true
Rectangle {
id: rect
color: "#ffffff"
width: 100; height: 100
MouseArea {
id: mouseArea
anchors.fill: parent
}
Connections {
target: mouseArea
onClicked: {
print("clicked")
}
}
}
}

How to use QtQuick.Window element in Qt5 and QML?

I recently installed the Qt5 RC2 for Mac OS X and started developing some QML applications. After looking at the new elements, I especially wanted to try the Window and Screen Element. (http://qt-project.org/doc/qt-5.0/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html)
So I set the imports at the top of the file like this:
import QtQuick 2.0
import QtQuick.Window 2.0
The import is found, but I can use neither Window nor Screen. Everytime I type Screen or Window an error appears which says "Unknown component (M300)"
Has anyone an idea what the problem is?
Sometimes QtCreator doesn't recognize some types/properties, mainly the ones that were not present in Qt4.x, but that doesn't mean you can't use them, so yes, 'Window' is unknown just like properties 'antialiasing', 'fontSizeMode' or 'active' are, but you can use them, here is an example of use for QtQuick.Window 2.0 :
import QtQuick 2.0
import QtQuick.Window 2.0
Window {
id: win1;
width: 320;
height: 240;
visible: true;
color: "yellow";
title: "First Window";
Text {
anchors.centerIn: parent;
text: "First Window";
Text {
id: statusText;
text: "second window is " + (win2.visible ? "visible" : "invisible");
anchors.top: parent.bottom;
anchors.horizontalCenter: parent.horizontalCenter;
}
}
MouseArea {
anchors.fill: parent;
onClicked: { win2.visible = !win2.visible; }
}
Window {
id: win2;
width: win1.width;
height: win1.height;
x: win1.x + win1.width;
y: win1.y;
color: "green";
title: "Second Window";
Rectangle {
anchors.fill: parent
anchors.margins: 10
Text {
anchors.centerIn: parent
text: "Second Window"
}
}
}
}
You just need to have a Window item as root object, and you can embed other Window items into it.

Resources