0
私はアンドロイドアプリケーションで作業しており、問題に直面しています。アプリケーションのページには、入力フィールドがいくつかありますが、そのうちの1つは日付用です。日付を選択するためにオンデマンドで開くカレンダーを追加するか、手動で日付を入力する必要があります。 TextInputとボタンをクリックすると、ローダーでカレンダーアイテムが作成され、ローダーのサイズが80に設定されます(最初は0でした)。これらのコンポーネントはすべて列レイアウトに含まれています。ボタンがクリックされると、他の入力フィールドの下にカレンダーが描画されます。Qt QMLコンポーネントのサイズを変更してページ全体を変更する方法
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
FocusScope {
id: root
Layout.preferredHeight: 20
property alias text: input.text
property alias border: background.border
property alias backgroundColor: background.color
property alias textColor: input.color
ColumnLayout{
anchors.fill: parent
spacing: 1
RowLayout{
Layout.fillHeight: true
Layout.fillWidth: true
Rectangle {
id: background
Layout.fillHeight: true
Layout.fillWidth: true
color: "darkgrey"
TextInput {
id: input
anchors.fill: parent
anchors.margins: 3
verticalAlignment: TextInput.AlignVCenter
focus: true
text: dateInput.selectedDate
}
}
CustomButton {
id: calandar
Layout.fillHeight: true
Layout.preferredWidth: 40
image: "icons/CalandarButton.svg"
onClicked: {
console.log("clicked calandar")
if(calendarLoader.status === Loader.Null){
calendarLoader.height = 80
calendarLoader.sourceComponent = Qt.createQmlObject("import QtQuick 2.5; import QtQuick.Controls 1.4; Calendar {}",
calendarLoader,
"calandarpp")
}
else{
calendarLoader.height = 0
calendarLoader.sourceComponent = undefined
}
}
}
}
Loader {
id: calendarLoader
Layout.fillWidth: true
height: 0
}
}
}
私はzがものをコーディネートしようとしたが、私は常に他のすべての下のカレンダーを取得しています。私はちょうどloader.activeものについて読んでいたので、今使っています。私のアプリケーションのページには他の入力フィールドが含まれています。このコンポーネントは他のコンポーネントです。ローダーをアクティブにすると、他の入力フィールドの下にカレンダーが描画されます。 –
この例では、 'qmlscene example.qml'として起動し、ボタンをクリックすると、'エラー:QObject *をQQmlComponentに割り当てることができません。 'というエラーが表示されます。 – Velkan
私のマシン上では、http://imgur.com/a/uwNIUここでは、カレンダーをアクティブにしたページのキャプチャを行います。カレンダーが入力された日付の上にあり、他のフィールドの下にどのように表示されますか? –