Die Popup-Höhe des QML-Kombinationsfelds wird in Qt 5.14 automatisch berechnetC++

Programme in C++. Entwicklerforum
Guest
 Die Popup-Höhe des QML-Kombinationsfelds wird in Qt 5.14 automatisch berechnet

Post by Guest »

Ich habe ein Qt-QML-Beispielprojekt entwickelt, das eine ComboBox enthält. Ich beobachte unterschiedliche Verhaltensweisen, wenn ich dieses Projekt unter Qt 5.14 und Qt 5.7 ausführe.
Insbesondere wird die Höhe des ComboBox-Popups in Qt 5.14 automatisch berechnet und angepasst, während dies bei dieser automatischen Höhenberechnung nicht der Fall ist treten in Qt 5.7 auf.
Ich habe die Qt-Dokumentation für beide Versionen überprüft, kann aber die Ursache dieser Diskrepanz nicht genau bestimmen. Kann mir bitte jemand dabei helfen?
============================== =============================
Das Folgende ist der Beispielprojektcode:

Code: Select all

import QtQuick 2.14
import QtQuick.Window 2.12
import QtQuick.Controls 2.12

Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")

Rectangle {
width: 300
height: 200

ComboBox {
id: myComboBox
x: 50
y: 50
width: 200

model: ListModel {
ListElement { text: "Option 1" }
ListElement { text: "Option 2" }
ListElement { text: "Option 3" }
ListElement { text: "Option 4" }
ListElement { text: "Option 5" }

}
currentIndex: 3

Component.onCompleted: {
console.info("height : ", myComboBox.height);
console.info("myComboBox.popup.height: ", myComboBox.popup.height);
console.info("myComboBox.model.count: ", myComboBox.model.count);
}
}
}
}
Der Code endet hier.
Dies ist die Anwendungsausgabe des Qt 5.14-Beispielprojekts:

Code: Select all

qml: height :  40
qml: myComboBox.popup.height:  205
qml: myComboBox.model.count:  5
=====================
Dies ist die Anwendungsausgabe von Qt 5.7 Beispielprojekt:

Code: Select all

qml: height :  40
qml: myComboBox.popup.height:  0
qml: myComboBox.model.count:  5

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post