qspinbox

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) }

How to use float in a QML spinbox

旧城冷巷雨未停 提交于 2019-12-11 02:03:06
问题 I use a QML Spinbox but I have trouble to use floats in it. If I write something like value: 5.0 , it will be displayed as 5 , so as an int instead of a float. Do you have any idea of how to proceed ? Thanks a lot and have a good day ! 回答1: You can create a Spinbox with custom texts DoubleSpinBox.qml import QtQuick 2.0 import QtQuick.Controls 2.1 Item { property int decimals: 2 property real realValue: 0.0 property real realFrom: 0.0 property real realTo: 100.0 property real realStepSize: 1.0

QSpinBox thousand separator

旧巷老猫 提交于 2019-12-06 07:43:27
问题 With a QSpinBox is it possible to display the thousand separator of a number while user enter it like 10,000 Which is the best way to do that ? 回答1: You could subclass QSpinBox and reimplement the textFromValue which is responsible for the display of the value to the spinbox widget. A possible implementation could be the following: QString MySpinBox::textFromValue(int value) { return this->locale()->toString(value); } Using locale is the best way since it will display the separator based on

How to subclass QSpinBox so it could have int64 values as maxium and minimum

自闭症网瘾萝莉.ら 提交于 2019-12-04 18:02:35
问题 I need to implement a QSpinBox control which should be able to process int64 values as it's minimum & maximum values. Current implementation only supports int32 values. End of the day my QSpinBox should accept any value between 9223372036854775807 and -9223372036854775808 What do I need to do, if I'm to achieve this by subclassing QAbstractSpinbox ? 回答1: Derive from QAbstractSpinBox . Add a QValidator to the QLineEdit to only allow valid int64 values. Add a property called value to provide

QSpinBox thousand separator

浪子不回头ぞ 提交于 2019-12-04 12:53:36
With a QSpinBox is it possible to display the thousand separator of a number while user enter it like 10,000 Which is the best way to do that ? pnezis You could subclass QSpinBox and reimplement the textFromValue which is responsible for the display of the value to the spinbox widget. A possible implementation could be the following: QString MySpinBox::textFromValue(int value) { return this->locale()->toString(value); } Using locale is the best way since it will display the separator based on the user's settings. i know this is late but this may help other people. i used this to update the

How to subclass QSpinBox so it could have int64 values as maxium and minimum

无人久伴 提交于 2019-12-03 11:48:11
I need to implement a QSpinBox control which should be able to process int64 values as it's minimum & maximum values. Current implementation only supports int32 values. End of the day my QSpinBox should accept any value between 9223372036854775807 and -9223372036854775808 What do I need to do, if I'm to achieve this by subclassing QAbstractSpinbox ? Derive from QAbstractSpinBox . Add a QValidator to the QLineEdit to only allow valid int64 values. Add a property called value to provide access to the int64 member that actually holds the value. Reimplment stepBy(int steps) to modify the number.

QSpinBox inside a QScrollArea: How to prevent Spin Box from stealing focus when scrolling?

孤者浪人 提交于 2019-12-03 11:00:49
问题 I have a control with several QSpinBox objects inside a QScrollArea. All works fine when scrolling in the scroll area unless the mouse happens to be over one of the QSpinBoxes. Then the QSpinBox steals focus and the wheel events manipulate the spin box value rather than scrolling the scroll area. I don't want to completely disable using the mouse wheel to manipulate the QSpinBox, but I only want it to happen if the user explicitly clicks or tabs into the QSpinBox. Is there a way to prevent

QSpinBox inside a QScrollArea: How to prevent Spin Box from stealing focus when scrolling?

柔情痞子 提交于 2019-12-03 02:34:27
I have a control with several QSpinBox objects inside a QScrollArea. All works fine when scrolling in the scroll area unless the mouse happens to be over one of the QSpinBoxes. Then the QSpinBox steals focus and the wheel events manipulate the spin box value rather than scrolling the scroll area. I don't want to completely disable using the mouse wheel to manipulate the QSpinBox, but I only want it to happen if the user explicitly clicks or tabs into the QSpinBox. Is there a way to prevent the QSpinBox from stealing the focus from the QScrollArea? As said in a comment to an answer below,

How do I set the background color of a widget like combobox or double spin box?

戏子无情 提交于 2019-11-28 10:40:20
I am trying to set the background color for a double spin box, and I am not sure what function I should use. I saw some function called SetBackgroundRole which accepts a Qt::ColorRole , but I am not sure how to use this one as well. Kindly let me know, what's the simple way to change the background color of a QComboBox or QDoubleSpinBox ? Jérôme Using a QPalette isn't guaranteed to work for all styles, because style authors are restricted by the different platforms' guidelines and by the native theme engine. To make sure your background color will be correct, I would suggest to use the Qt

How do I set the background color of a widget like combobox or double spin box?

瘦欲@ 提交于 2019-11-27 03:43:52
问题 I am trying to set the background color for a double spin box, and I am not sure what function I should use. I saw some function called SetBackgroundRole which accepts a Qt::ColorRole , but I am not sure how to use this one as well. Kindly let me know, what's the simple way to change the background color of a QComboBox or QDoubleSpinBox ? 回答1: Using a QPalette isn't guaranteed to work for all styles, because style authors are restricted by the different platforms' guidelines and by the native