Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.191.132.194] |
|
Сообщ.
#1
,
|
|
|
Добрый день. Столкнулся с одной загадкой.
Написал я свой DataPicker, все работает, все прекрасно, но только на декстопе. Под андроидом после вызова окно приложения сжимается до размеров диалога, что есть очень не хорошо. На видео собственно проблема. Ну и код ниже import QtQuick 2.7 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.2 Rectangle { id: root anchors.rightMargin: 15 anchors.leftMargin: 10 anchors.topMargin: 20 height: 40 color: "#ddd3de" radius: 5 property var tempDate: new Date(); property string pText: "" TextField { id: dateField anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter placeholderText: pText width: (parent.width )*0.8 height: 40 font.pointSize: 10 readOnly: true } Image { id: calendar2 anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter source: "qrc:/res/calendar_icon.png" scale: 0.6 } MouseArea { anchors.fill: parent onClicked: { dialogCalendar.show(tempDate) } } Dialog { id: dialogCalendar width: 350 height: 300 title: qsTr("Select Date") property date selectedDate: new Date contentItem: Rectangle { id: dialogRect color: "#f7f7f7" Calendar { id: calendar anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right anchors.bottom: row.top style: CalendarStyle { navigationBar: Rectangle { height: 48 color: "#f7f7f7" Rectangle { color: "#d7d7d7" height: 1 width: parent.width anchors.bottom: parent.bottom } Button { id: previousYear width: parent.height - 8 height: width anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left onClicked: control.showPreviousYear() style: ButtonStyle { background: Rectangle { Image { source: "qrc:/res/double_left_arrow.png" width: parent.height - 8 height: width } } } } Button { id: previousMonth width: parent.height - 8 height: width anchors.verticalCenter: parent.verticalCenter anchors.left: previousYear.right anchors.leftMargin: 8 onClicked: control.showPreviousMonth() style: ButtonStyle { background: Rectangle { Image { source: "qrc:/res/left_arrow2.png" width: parent.height - 8 height: width } } } } Label { id: dateText text: styleData.title color: "#34aadc" elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter font.pixelSize: 16 anchors.verticalCenter: parent.verticalCenter anchors.left: previousMonth.right anchors.leftMargin: 2 anchors.right: nextMonth.left anchors.rightMargin: 2 } Button { id: nextMonth width: parent.height - 8 height: width anchors.verticalCenter: parent.verticalCenter anchors.right: nextYear.left onClicked: control.showNextMonth() style: ButtonStyle { background: Rectangle { Image { source: "qrc:/res/right arrow2.png" width: parent.height - 8 height: width } } } } Button { id: nextYear width: parent.height - 8 height: width anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right onClicked: control.showNextYear() style: ButtonStyle { background: Rectangle { Image { source: "qrc:/res/double_right_arrow.png" width: parent.height - 8 height: width } } } } } dayDelegate: Rectangle { anchors.fill: parent anchors.margins: styleData.selected ? -1 : 0 color: styleData.date !== undefined && styleData.selected ? selectedDateColor : "transparent" readonly property color sameMonthDateTextColor: "#444" readonly property color selectedDateColor: "#34aadc" readonly property color selectedDateTextColor: "white" readonly property color differentMonthDateTextColor: "#bbb" readonly property color invalidDateColor: "#dddddd" Label { id: dayDelegateText text: styleData.date.getDate() anchors.centerIn: parent horizontalAlignment: Text.AlignRight font.pixelSize: 10 color: { var theColor = invalidDateColor; if (styleData.valid) { theColor = styleData.visibleMonth ? sameMonthDateTextColor : differentMonthDateTextColor; if (styleData.selected) theColor = selectedDateTextColor; } theColor; } } } } } Row { id: row height: 48 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom Button { id: dialogButtonCalCancel anchors.top: parent.top anchors.bottom: parent.bottom width: parent.width / 2 - 1 style: ButtonStyle { background: Rectangle { color: control.pressed ? "#d7d7d7" : "#f7f7f7" border.width: 0 } label: Text { text: qsTr("Cancel") font.pixelSize: 14 color: "#34aadc" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } } onClicked: dialogCalendar.close() } Rectangle { id: dividerVertical width: 2 anchors.top: parent.top anchors.bottom: parent.bottom color: "#d7d7d7" } Button { id: dialogButtonCalOk anchors.top: parent.top anchors.bottom: parent.bottom width: parent.width / 2 - 1 style: ButtonStyle { background: Rectangle { color: control.pressed ? "#d7d7d7" : "#f7f7f7" border.width: 0 } label: Text { text: qsTr("Ok") font.pixelSize: 14 color: "#34aadc" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } } onClicked: { tempDate = calendar.selectedDate dateField.text = Qt.formatDate(tempDate, "dd.MM.yyyy"); dialogCalendar.close(); } } } } function show(x){ calendar.selectedDate = x dialogCalendar.open() } } } |
Сообщ.
#2
,
|
|
|
Неужели ни у кого подобной проблемы не было? Я грешу на Dialog, но не уверен. Пробовал менять paretWindow, не помогло.
|
Сообщ.
#3
,
|
|
|
Какие нить средства дебага есть?
|
Сообщ.
#4
,
|
|
|
Цитата JoeUser @ Какие нить средства дебага есть? Ну стандартные, те что с креатором и студией идут. |
Сообщ.
#5
,
|
|
|
Надо пробовать дебажить. Я с этой шляпой не сталкивался. Но некоторве конструкции, а-ля:
width: parent.height - 8 height: width позволяют задумываться. Дебажить надо. |
Сообщ.
#6
,
|
|
|
JoeUser, спасибо, попробую. Получится - напишу. Не получится - тоже.
|