Details
-
Sub-task
-
Resolution: Duplicate
-
P0: Blocker
-
None
-
None
-
Qt5.9.2, QtQuick 2.9, QtQuick Controls 2.2, Samsung Note 5 with Android 7.0 and tested with screen resolutions HD(1280*720) FHD(1920*1080) and WQHD(2560*1440), Windows 10 for development.
Description
In Qt5.9.2, I created a black rectangle inside a red ApplicationWindow for Samsung Note-5 with screen resolutions 1280*720, 1920*1080, 2560*1440 and Android-7.0 in two ways:
- A rectangle having the same width and height of the ApplicationWindow
- anchors.fill : parent
But in both ways the response is same - rectangle doesn't fill the entire ApplicationWindow. You can see about a pixel line on top side and about a pixel line on right side of the ApplicationWindow which is not filled. Even if I make a much larger Rectangle than the ApplicationWindow itself, I get the same output.
I noticed that If I try to nest rectangles and fill the parent rectangle with a child one then I get the completely filled parent rectangle without any issues.
I also noticed that if I comment the following line of code, the problem goes away but this is not the solution as then the UI elements don't scale with respect to the device screen sizes.
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
Here I have attached a picture and a working project for testing.
main.qml:
import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 ApplicationWindow { id: appWindow visible: true /* Developing mobile apps you don’t need to set width and height, because the ApplicationWindow always grabs the total available space. */ color: "#ff0000" // Red color /* For some reasons I want this Rectangle here * and it MUST fill the entire window but I notice * a pixel or two line on top and right of the * screen. */ Rectangle { width: appWindow.width; height: appWindow.height //anchors.fill: parent // same output color: "#000000" // Black color } }
main.cpp
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { /* Commenting the following line resolves the issue but with other problems */ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QLatin1String("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }