Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Different types in connections



  • That is more a question a about best design using the qt classes. I have done a program and several times I have to perform some conversion from string(QLineEdit for example) to double and vice versa. I would like to know from more experience programmer if it is better to use QVariant to all basic types or you use other approach.


  • Lifetime Qt Champion

    Hi,

    Generally when you have to do such conversions often, the first question that comes to my mind is: am I using the right tool ?

    For number input, you should rather use QSpinBox or QDoubleSpinBox, if you need another type you can even subclass QAbstractSpinBox.

    Hope it helps


Log in to reply