亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

QtQuick GeometryChanged 方法僅適用于加載組件的一個方向

QtQuick GeometryChanged 方法僅適用于加載組件的一個方向

海綿寶寶撒 2021-09-02 17:25:11
我正在構建一個 Python + QtQuick 應用程序,它需要一個從QQuickPaintedItem 降級的類。我在管理已繪制項目的布局和大小時遇到了一些麻煩。特別是,我有一個看起來像這樣的應用程序左側有一組按鈕,窗口右側是一個加載程序(這是一個很好的理由,這只是演示問題的最小示例)。主 qml 文件 ( main.qml) 如下所示:import QtQuick 2.7import QtQuick.Controls 2.1import QtQuick.Layouts 1.3ApplicationWindow {    id: mainWindow    visible: true    width: 720    height: 480    title: qsTr("QML Sampler")    onClosing: main.close_application()    RowLayout {        anchors.fill: parent        ColumnLayout {            id: sideBar            Layout.fillHeight: true            Layout.preferredWidth: 200            Layout.minimumWidth: 150            Layout.maximumWidth: 350            Button {                id: buttonScreen1                text: "Button 1"                Layout.fillWidth: true            }            Button {                id: buttonScreen2                text: "Button 2"                Layout.fillWidth: true            }        }        Loader {            id: contentAreaLoader            Layout.fillHeight: true            Layout.preferredWidth: 520            Layout.minimumWidth: 300            source: 'loaded_content.qml'        }    }}加載的內容文件是實際包含自定義類的文件,如下所示 ( loaded_content.qml):import QtQuick 2.7import QtQuick.Controls 2.1import QtQuick.Layouts 1.3import CustomPaintedItem 1.0ColumnLayout {    anchors.fill: parent    Label {        text: "Here's a thing!"    }    CustomPaintedItem {        Layout.fillHeight: true        Layout.fillWidth: true    }}
查看完整描述

1 回答

?
嚕嚕噠

TA貢獻1784條經驗 獲得超7個贊

在不使用 Loader 的情況下,布局僅處理子項:ColumnLayout自 amaximumWidth建立以來,它占用可用空間,因此它將是無限的(可以等價于 的一切Layout.fillWidth: true)。另一方面,不是 Layout 的 Loader 沒有該大小策略,因此如果您希望它占用所有可用空間,則必須Layout.fillWidth: true明確使用。


Loader {

    id: contentAreaLoader

    Layout.fillHeight: true

    Layout.preferredWidth: 520

    Layout.minimumWidth: 300

    Layout.fillWidth: true // <----

    source: 'loaded_content.qml'

}


查看完整回答
反對 回復 2021-09-02
  • 1 回答
  • 0 關注
  • 295 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號