qtquickcontrols2

QML - Vertical Swipe View?

允我心安 提交于 2019-12-14 02:04:52
问题 Is it possible to use the SwipeView in QML for vertical swiping rather than horizontal? I'd like the Page contents of a SwipeView to float vertically, so a user has to scroll up and down to navigate between Pages. If this is not possible how would I go about it? UPDATE This functionality has been added to QT as seen here: http://doc-snapshots.qt.io/qt5-dev/qml-qtquick-controls2-swipeview.html#orientation-prop 回答1: After some more research I came up with a solution that works fine, using a

Easy way to configure QML combobox with 1-25

为君一笑 提交于 2019-12-13 03:45:35
问题 I have a need for a simple drop-down box containing the numbers 1 through 25 inclusive. If I set the model up as a simple 25 , I get the values 0 through 24 inclusive. I know I can have a more complicated list model but it seems rather silly to construct a massive array of values when they should be able to be calculated on the fly. From what I read, it should be a simple matter to create a delegate for setting the display values but, with the QML: ComboBox { width: 100 model: 25 delegate:

QML: Resize CheckBox

為{幸葍}努か 提交于 2019-12-12 17:21:53
问题 I have ListView with my own delegate. import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 ItemDelegate { height: 40 Row { spacing: 10 anchors.verticalCenter: parent.verticalCenter CheckBox { } } } The problem is that check boxes does not resize despite ItemDelegate's height. I get this for height = 40: I get this for height = 10: I've tried playing with CheckBox'es width and height values - did not help. Is it possible to make it smaller at all, without customizing it?

Access QML StackView from a control

谁说我不能喝 提交于 2019-12-12 02:27:45
问题 Sorry for probably a stupid question - I'm very new to QML. One of my StackView's pages: Page { id : root header: ToolBar { BackButton { anchors.left: parent.left } } } BackButton code: Button { text: "<" font.pixelSize: 20 width: 30 onClicked: parent.root.StackView.view.pop() } I've tried parent.StackView also. No luck. Getting: TypeError: Cannot call method 'pop' of null Is there a solution? 回答1: I'd suggest something like this. main.qml: import QtQuick 2.6 import QtQuick.Controls 2.0

How to implement Master Details View in Qt/QML (part 2)

99封情书 提交于 2019-12-12 00:57:00
问题 I previously asked how to implement a Master Details View in Qt/QML here: How to implement a master-details view Qt/QML on an Android tablet?. Having continued working on this, I came out with the following mockup QML layout: import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 import QtQuick.Controls 1.4 Item { y: 50 Layout.fillHeight: true width: appWindow.width RowLayout { id: mainLayout anchors.fill: parent ListModel { id: navigation ListElement { item: "Item 1" }

WorkerScript access to Controller class

我们两清 提交于 2019-12-11 16:57:45
问题 I have a BusyIndicator which should spin while heavy computations are happening and stop when the computations are done. I thought WorkerScript was the right way to go but but from here, it seems that the secondary (computation thread) in the .js file does not have access to the objects of the primary .qml thread. This is problematic as all my computations are performed through a Controller C++ defined QObject instantiated by the primary thread. Here is my code: main.qml import QtQuick 2.7

How to solve module “”QtQuick.Controls“ version 2.0 is not installed” on mac

自古美人都是妖i 提交于 2019-12-11 11:03:57
问题 I've been getting the error "module "QtQuick.Controls" version 2.0 is not installed" on Qt Creator 5.6.13, so i upgraded to 5.11.2 and i'm still getting it. Here's the part causing it: import QtQuick.Controls 2.0 Thank you for your help. 回答1: Make sure you activated your Qt kit in Projects > Build & Run as follow: 回答2: Ok so, I was building with the Qt Creator 5.6.3 compiler. Projects => Build & Run => change to the corresponding kit . 来源: https://stackoverflow.com/questions/53374106/how-to

Process native events of a window created by QQmlApplicationEngine

假装没事ソ 提交于 2019-12-11 07:32:28
问题 There is QWidget::nativeEvent for widget windows. Is there some analogue for windows created by QML ? I want to process some messages of main window ( ApplicationWindow ). Main window is created by QML code which is loaded by QQmlApplicationEngine . Should I use QCoreApplication::installNativeEventFilter? 来源: https://stackoverflow.com/questions/50900006/process-native-events-of-a-window-created-by-qqmlapplicationengine

Qt 5.12 TableView Header Delegate

孤人 提交于 2019-12-11 04:53:55
问题 I've created this table view in Qt 5.12 with new TableView but I don't know how to create header for it, I read documentation there is no headerdelegate for it neither. Here some screenshot: so how can i add headerDelegate for 5.12 TableView? import QtQuick 2.12 import QtQuick.Controls 2.12 ApplicationWindow { visible: true ListModel{ id:tableModel ListElement{ identifier:1 name:'value' title: 'test' } ListElement{ identifier:2 name:'value2' title: 'test2' } } width:1000; height: 500 //

Custom spinbox with “classic” spinbox display

爷,独闯天下 提交于 2019-12-11 02:47:21
问题 I need to use a double spinbox for my QML view and in this case, I based my spinbox on this example . SpinBox { id: spinbox from: 0 value: 110 to: 100 * 100 stepSize: 100 anchors.centerIn: parent property int decimals: 2 property real realValue: value / 100 validator: DoubleValidator { bottom: Math.min(spinbox.from, spinbox.to) top: Math.max(spinbox.from, spinbox.to) } textFromValue: function(value, locale) { return Number(value / 100).toLocaleString(locale, 'f', spinbox.decimals) }