我正在使用QML中的一个小消息对话窗口系统。为此,我使用带有Loader的容器来加载不同的消息(这些消息不仅仅是文本,而是放置文本和图形符号,因此为每条消息加载QML文件)。默认情况下,这些消息窗口具有相同的大小,因此我直接在容器中包含我的大小信息。但是有些消息可能会更长,因此如果超出默认值,我正在寻找一种方法来使用我加载的组件的height
。
我认为我的问题可以分为三个部分:
Loader
对象访问已加载组件的大小信息?有什么建议吗?
答案 0 :(得分:3)
您可以使用item keyword
访问加载的对象。
例如,如果您的加载程序ID为idLoader
,则创建的项目为idLoader.item
,您有2个解决方案可以执行您想要的操作:
1:如何通过我的loader对象访问加载组件的大小信息?
Loader{
id:idLoader
width: (item !== null && typeof(item)!== 'undefined')? item.width : 0
height: (item !== null && typeof(item)!== 'undefined')? item.height: 0
}
2:如何根据孩子的尺寸设置容器尺寸? &安培;如何选择性地使用更大的尺寸?
Loader{
id:idLoader
width: childrenRect.width
height : childrenRect.height
}
答案 1 :(得分:1)
这是一个未经测试的想法。取儿童首选身高或硬编码最小值的最大值,以较大者为准。
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\Program Files\WindowsApps\Microsoft.WindowsPreview.Kinect.8.1_2.0.1410.19000_x86__8wekyb3d8bbwe\WindowsPreview.Kinect.winmd'. Module was built without symbols.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Diagnostics.Debug\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Diagnostics.Debug.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\system32\WinMetadata\Windows.Globalization.winmd'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Collections\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Collections.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\system32\WinMetadata\Windows.Foundation.winmd'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.WindowsRuntime.UI.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.WindowsRuntime.UI.Xaml.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Threading\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Threading.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ObjectModel\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.ObjectModel.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\system32\WinMetadata\Windows.Storage.winmd'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\system32\WinMetadata\Windows.Data.winmd'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IO\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.IO.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization.Xml\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.Serialization.Xml.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Internals\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Internals.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Cannot find or open the PDB file.
'App14.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file.
The program '[9472] App14.exe' has exited with code 1 (0x1).