0
votes

So I'm trying to create an application in QML, and doing so by using an ApplicationWindow. The following code is in main.qml, where some of the components are defined in other files (they are not essential for this problem):

import QtQuick 2.12
import QtQuick.Extras 1.4
import QtQuick.Controls 2.5
import QtQuick.Controls.Styles 1.4
import QtQuick.Window 2.3
import QtDataVisualization 1.3
import Qt3D.Core 2.9
import Qt3D.Render 2.9
import QtCharts 2.3

ApplicationWindow {
    id: window
    width: 1280
    height: 720
    //visibility: ApplicationWindow.FullScreen
    visible: true
    color: "#444444"

    Speedometer {
        id: speedometer
        x: 49
        y: 144
        width: 306
        height: 320
        minValue: 0
        maxValue: 600
        visible: true
    }

    Thermometer {
        id: thermometer
        x: 1170
        y: 233
        scale: 2
        minValue: 0
        maxValue: 50
        visible: true
    }

    Slider {
        id: slider
        from: 0
        to: 100
        x: 28
        y: 594
        width: 1224
        height: 98
        font.pointSize: 14
        hoverEnabled: false
        enabled: false
        live: true
        snapMode: Slider.NoSnap
        value: 0
        visible: true

        Behavior on value {
            NumberAnimation {
                 duration: 200
            }

         }
         background: Rectangle {
            x: slider.leftPadding
            y: slider.topPadding + slider.availableHeight / 2 - height / 2
            implicitWidth: 200
            implicitHeight: 4
            width: slider.availableWidth
            height: implicitHeight
            radius: 2
            color: "#999999"
        }

        handle: Rectangle {
            x: slider.leftPadding + slider.visualPosition * (slider.availableWidth - width)
            y: slider.topPadding + slider.availableHeight / 2 - height / 2
            implicitWidth: 26
            implicitHeight: 26
            radius: 13
            color: "#0099ff"
        }

    }
    Timer {
        interval: 200
        running: true
        repeat: true
        property var distance: Math.random
        onTriggered: update()
    }
    function update(){
        var distance = (Math.random() * 0.03) + 0.1;
        var speed = (distance * 50) / 0.02;
        slider.value = slider.value + distance;
        speedometer.value = speed;
        thermometer.value = Math.random() * 25 + 25;
    }

    DataManager {
        id: manager
        onNewVelocity: {
            lineSeries.append(velocity.x, velocity.y)
            chartView.title = name
        }
    }

    Timer {
        id: timer
        repeat: true
        interval: 1
        onTriggered: {
            manager.dummyData();
        }
    }

    Chart {
        id: chart
        height: 250
        width: 250
        x: 1000
    }

    Text {
        id: labelText
        color: "white"
        width: 300
        height: 100
    }

    Button {
        id: startThread
        text: "Start"
        onClicked: {
             timer.start()
        }
    }

    Button {
        id: stopThread
        text: "Stop"
        x: 200
        onClicked: {
            timer.stop()
        }
    }
    
    Button {
        id: clearGraph
        text: "Clear"
        x: 100
        onClicked:  {
            lineSeries.clear()
        }
    }
}

The content itself isn't that important, but the thing that is, is the fact that when I personally run the project, the application window doesn't show what it is supposed to. And I'd like to emphasize: I'm collaborating with others on this exact project, and when they run the exact same code as me, they get different results.

The first image is what I get when running the code:

MyPOV

The second image is what they get, and what is actually supposed to show when running the code:

Actually correct view

So I've been trying to search Google for every possible solution, but have found nothing. I've reinstalled Qt and QtCreator, but to no prevail. We are running the exact same thing, but I'm the only one that don't see all components show up. The first image is way more zoomed in than the latter, and I'd really like if anyone knew how to fix this. I've struggled to find anything that could help so far (Extra note: the code I ran didn't include the graph as it wasn't up to date with current version on git, but the other things remain the same. So the bar below and the thermometer component on the right SHOULD be visible, but they're not).

1
Are you by any chance on a high dpi monitor, like 4K? Maybe it's doing auto-scaling incorrectly. Do you have the QT_AUTO_SCREEN_SCALE_FACTOR environment variable set to true?JarMan
Thank you for the response! I'm not using a 4k monitor (I'm using a laptop with the same resolution as the others that I'm working with), but I did search around for QT_AUTO_SCREEN_SCALE_FACTOR, and launching QtCreator via a .bat file seemed to solve the problem. I'll show the solution below, thank you for the help :)Matty

1 Answers

0
votes

I eventually found a solution to what seems to be a bug from Qt's end. I had to launch QtCreator via a qtcreator.bat file in the same directory as qtcreator.exe with the following content:

@echo off
set QT_SCALE_FACTOR_ROUNDING_POLICY=Round
set QT_AUTO_SCREEN_SCALE_FACTOR=0
qtcreator.exe

When I now run the project, it shows the correct scale :)