也就是說,在textField元素和Button之間有一些額外的像素空間。
我試圖使用QML行元素來重新創建這個影像,如下所示
Window {
寬度: 640
高度。480
可見。true
標題。qsTr("Hello World"/span>)
行{
id:row_element
anchors.horizontalCenter: parent.horizontalCenter
spacing:20
width: implicitWidth
height: implicitHeight
RadioButton{
id:min_timer_id
文本。"100"。
間隔。5
}
RadioButton{
id:max_timer_id
文本。"500"/span>
間隔。5
}
RadioButton{
id:custom_entry_rb
文本。"custom"
間隔。5
寬度: 100。
}
TextField{
id:custom_entry
placeholderText: "輸入自定義時間"。
寬度: 200。
}
按鈕{
id:buttonId
文本。"啟動計時器"
寬度: 200。
間隔。100
}
}
}
我無法設定文本欄位和按鈕之間的自定義間距,是否有辦法使用行元素進行設定?
我目前的用戶界面看起來像這樣:-
uj5u.com熱心網友回復:
如果你需要把它放在一個Row內,我只需要添加一個不可見的Item作為間隔。
Row {
間隔。20
RadioButton {}
RadioButton {}
文本欄位 {}
//size this to whatever you need.。
專案 { 高度。1; width: 50 }
按鈕 {}。
}
uj5u.com熱心網友回復:
你可以使用一個具有Layout.fillWidth: true的RowLayout和一個Item。
importQtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
視窗 {
寬度:640
高度。480
可見。true
標題。qsTr("Hello World"/span>)
RowLayout {
id: row_element
間隔。20
anchors.top: parent.top
width: parent.width: parent.width
RadioButton {
id: min_timer_id
text: "100"。
間隔。5
}
RadioButton {
id: max_timer_id
文本。"500"/span>
間隔。5
}
RadioButton {
id: custom_entry_rb
文本。"custom"
間隔。5
寬度: 100。
}
TextField {
id: custom_entry
placeholderText: "輸入自定義時間"。
寬度: 200。
}
專案{
Layout.fillWidth: true
}
按鈕{
id: buttonId
text: "開始計時器"
寬度: 200。
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/310184.html
標籤:


