QML Window opacity doesn't work when fullscreen - qt

I've experienced a strange problem: when a QML Window is fullscreen, its opacity property doesn't work, so the window stay opaque. When the window isn't fullscreen (e.g. maximized), it works properly.
Do you have any ideas how to deal with this problem?
In fact, I want to animate fullscreen window fading in.
The code:
main.qml
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Window 2.1
Window {
visible: true
visibility: "FullScreen"
opacity: 0.5
Text {
id: text
text: "Hello World"
font.pointSize: 36
color: "#333"
}
}
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();
}
I use Qt 5.3 on Windows 8.1.

This is the age-old bug of the Qt/Win combination - windows with an OpenGL context, can't be made transparent without employing trickery. The solution is to embed your QML application in a QQuickWidget and make that transparent and full-screen. There also exists another workaround (using the 'DWM' API, which is nonportable - you can read about it in the bug description).
https://bugreports.qt.io/browse/QTBUG-28214

Related

QtWebEngine displays partially without margins

WebEngineView should be displayed in the whole window, but it's not. Right margin strip and bottom margin strip is not displayed. Instead a strip of (red) background is visible. Yet I can click on red background on the input search formular and it can be filled. There shouldnt be any background visible.
I also tried QWebEngineView instead of QQmlApplicationEngine and it is exactly the same.
This code is run by Qt 6.4.0.
In Qt 5.12.5 it is displayed correctly.
What to do to show WebEngineView in the whole window ?
main.cpp:
int main(int argc, char *argv[])
{
QtWebEngineQuick::initialize();
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/webengine.qml")));
return app.exec();
}
webengine.qml:
import QtQuick
import QtQuick.Window
import QtWebEngine
Window {
width: 800
height: 600
visible: true
color: "red"
WebEngineView {
id: webEngineView
anchors.fill: parent
url: "https://doc.qt.io/qt-6/qtwebengine-webenginequick-minimal-example.html"
}
}
The gui:
This should already be fixed in 6.4.0, was this observed during the beta, if so, then try with the final release. If observed with the final, please open a bug report for at Qt.

Display bug when moving a transparent window QtQuick

So for my current project I need to use a transparent window.
On the creation of the window no problem it works is when you move the window that there is a problem.
The transparency does not apply because it considers that the window is part of the background and reproduces it in the new rendering.
I do not know if I'm very clear I put a picture in link it's more speaking sorry for the quality I had to take it with the laptop because when we capture it "refresh" the display and transparency becomes normal again.
Another surprising thing is that the transparency does not bug if what is behind is chrome ...
So basically the question is how to have a "normal" behavior?
Here I hope that you can help me I see no solution there.
At the code level:
main.cpp :
#include <QQuickView>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QQuickView * view = new QQuickView;
view->setTitle("Test");
view->setSource(QUrl::fromLocalFile ("main.qml"));
view->setColor(Qt::transparent);
view->show();
return a.exec();
}
main.qml :
import QtQuick 2.0
Rectangle {
width: 400
height: 400
color : "#00000000"
Rectangle {
anchors.centerIn: parent
color: "red"
width: 100
height: 100
}
}
Result

Rectangle as a root element in QML

I use Qt 5.5.0 MSVC 2013, 32bit.
I want to create minimal QtQuick application. When I choose New Project - Qt Quick Application I got project with 2 QML files: main.qml and MainForm.ui.qml. Since I do not need them, I delete second one and paste following to main.qml:
Import QtQuick 2.4
Rectangle{
id: root
visible: true
color: "gray"
width: 400
height: 800
}
But when I run project I got nothing. I see application in Task Manager but there is no application window.
Question: Is it possible to create .qml file with Rectangle as a root element?
Solution was found at official Qt Forum.
The template for creating Qt Quick Application adds QQmlApplicationEngine to launch the QML. But QQmlApplicationEngine dont work directly with Rectangle or Item as root element but requires any window like Window or ApplicationWindow.
So to make it work for Rectangle use QQuickView instead of QQmlApplicationEngine.
I changed content of main.cpp to
#include <QGuiApplication>
#include <QQuickView>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQuickView *view = new QQuickView;
view->setSource(QUrl("qrc:/main.qml"));
view->show();
return app.exec();
}
and it solved my problem.

Why does a TextArea with NoWrap always cause an "anchor loop detected" warning?

Why is a TextArea with
wrapMode: TextEdit.NoWrap
always causing
file:///C:/Qt/5.5/mingw492_32/qml/QtQuick/Controls/ScrollView.qml:340:13: QML Item: Possible anchor loop detected on fill.
when I run it?
I am running Qt 5.5 on a 64-bit Windows 7 machine, and compiling with MinGW.
Here is my QML code test.qml:
import QtQuick 2.4
import QtQuick.Controls 1.3
ApplicationWindow {
title: "test window"
width: 500
height: 500
visible: true
TextArea {
wrapMode: TextEdit.NoWrap
}
}
Here is my C++ code main.c:
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/test.qml")));
return app.exec();
}
Even if I add anchors.fill: parent to the TextArea, I still get the warnings.
As a second part of this question, is this warning something I should be worried about, or is it something I can safely ignore?
I think it's a bug from Qt, you can ignore it.
When created, TextArea have a width != 0, even if it's empty. When you enter a text that have an implicitWidth smaller then the (default) width of the TextArea, you will get this warning.
A workaround is to assign the wrapMode property in the Component.onCompleted handler:
Component.onCompleted: wrapMode = TextEdit.NoWrap

QML: not able to see text on TextInput element of QML

I have created qml/test.qml file as:
import QtQuick 1.0
Rectangle
{
id: pahe
width: 200; height: 50
color: "#55aaee"
TextInput
{
id: editor
anchors
{
left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
verticalCenter: parent.verticalCenter
}
cursorVisible: true;
font.bold: true
color: "#151515";
selectionColor: "Green"
focus: true
}
}
and One qml/main.cpp file as:
#include <QApplication>
#include <QtDeclarative>
#include <QDeclarativeView>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("test.qml"));
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.show();
return app.exec();
}
I am compiling this main.cpp file using commands like:
#qmake -project
#qmake
#make
and I am running the exe as:
./qml
So problem is that I am not able to see any text on TextInput even after entering text using key board. If i print the TextInput.text of element it shows entered text on console log but can not see on screen.
What could be the reason?
If i run same test.qml file using qmlviewer it works fine.
Any hint or comment in this would be helpful.
Thanks,
KBalar
why don't you try simulator? U said, it as an exe and why r u running it in a Linux style "./". If you still have the problem, check the background of the Rectangle or TextEdit and the font color.
The problem was with virtual Linux machine running on Windows PC. So If i run same example on Real Linux machine The problem wont be there.

Resources