|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A collection of C++ classes and QtQuick QML components for use with the Qt framework.
License: Other
Hi. I am writing my first QML application and am running into troubles. I am using your MLDoubleSpin box and it behaves slightly differently than the SpinBox. I am hoping you will see my mistake if I have one.
What I have works, until I press the + or - buttons on the spinbox. It then appears to overwrite my value and will no longer pull up the value from the c++ code. As far as I can tell, the SpinBox which uses integers, doesn't have this behaviour.
QML UI file
'ComboBox {
id: comboBox1
anchors.right: parent.right
anchors.rightMargin: 40
anchors.verticalCenter: parent.verticalCenter
textRole: "key"
valueRole: "value"
model: ListModel {
ListElement {
key: "7/8, 50 ohm"
value: 1
}
ListElement {
key: "1 5/8, 50 ohm"
value: 2
}
}
onCurrentValueChanged: _page3.preset = currentValue
}
.........
MLDoubleSpinBox {
id: spin3
anchors.right: parent.right
anchors.margins: 10
decimals: 3
from: 0
to: 30
value: _page3.outer
onValueChanged: _page3.outer = value
stepSize: 0.1
}
'
c++ header
'class CalcP3: public QObject
{
Q_OBJECT
Q_PROPERTY(double outer READ getOuter WRITE setOuter NOTIFY update)
.......
}'
c++ class
{
void CalcP3::setPreset(double value){
if (value == m_preset) return;
m_preset = value;
switch(m_preset) {
case 1:
m_outer = 0.785;
m_inner = 0.341;
break;
case 2:
m_outer = 1.527;
m_inner = 0.664;
break;
}
emit update();
}
........
'
Hello. I have found this while updating from Qt 9.1 to Qt 5.12.2
MLDoubleSpinBox has been used as delegate:
MLDoubleSpinBox {
from: model.min
to: model.max
stepSize: model.stepsize
onValueChanged: model.value = value
wrap: false
}
In Qt 5.9.1 it works great as expected:
But not in Qt 5.12.2 (same model as in the above example):
OS: Win7x64
Compiler: Mingw5.3x86 for Qt5.9.1 and Mingw7.3x86 for Qt5.12.2
Hello! Оnce again) Playing around with MLDoubleSpinBox I have found that it's text field does not updates properly if you enter value out of [from - to] range more than one time.
For the instance, let's use "controls/test.qml". MLDoubleSpinbox instance with "Default" label prepared to work in range from 0 to 10.
Step 2. Write, for the instance, 20 in the text field by keyboard
Step 3. Press 'Enter', value adjusted to top limit - it is ok, as expected
Step 4. Once again write 20, or whatever
Step 5. Press 'Enter', oops - it is not working now (
Step 6. Even if I change focus, MLDoubleSpinBox still contains 20
My specs.: MS Windows7x64
Qt: 5.9.1, 5.12.2
Compiller: Mingw32
Your implementation of the DoubleSpinBox for Qt Quick Controls 2 is very interesting. Thanks!
But in order to port code using Qt Quick Controls 1, one would need the support for the prefix and suffix properties.
As mentioned in the doc: prefix and suffix.
I have added it to the floating point SpinBox example from Qt Quick Controls 2 doc like this:
property string prefix: ''
property string suffix: ''
[...]
textFromValue: function(value, locale) {
return prefix + Number(value / 100).toLocaleString(locale, 'f', decimals) + suffix
}
valueFromText: function(text, locale) {
var numberStr = text.replace(suffix, '').replace(prefix, '');
return Number.fromLocaleString(locale, numberStr) * 100
}
Some types have been renamed in Qt 6, for instance "RegExValidator" got "RegularExpressionValidator".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.