Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to get comma as decimal separator in line edits?
Forum Updated to NodeBB v4.3 + New Features

How to get comma as decimal separator in line edits?

Scheduled Pinned Locked Moved Solved Qt for Python
19 Posts 6 Posters 8.0k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bkvldr
    wrote on last edited by bkvldr
    #6

    @Denni-0
    My project is a private learning project. I have no dead-line, and I am free to reconsider my approach. Guess I have to do som reading on MCV. Are the models provided by Qt really so troublesome as your post gives me the impression of ? Sent you a PM (or was it a chat)

    1 Reply Last reply
    0
    • kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #7

      @Denni-0, dude, what are you babbling about and what does it have to do with the question? Even I got confused ...

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      2
      • B Offline
        B Offline
        bkvldr
        wrote on last edited by
        #8

        I find Denni 0's post very interesting, but I would definitely appreciate a follow up on my original question. I would like to know if I can finish the application with my approach.

        I use QSqlRelationalTableModel and QDataWidgetMapper. How can I display numeric data from the database in lineedits according to my locale, with decimal comma instead of decimal point?

        Please see posts above.

        JonBJ JKSHJ 2 Replies Last reply
        0
        • B bkvldr

          I find Denni 0's post very interesting, but I would definitely appreciate a follow up on my original question. I would like to know if I can finish the application with my approach.

          I use QSqlRelationalTableModel and QDataWidgetMapper. How can I display numeric data from the database in lineedits according to my locale, with decimal comma instead of decimal point?

          Please see posts above.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #9

          @bkvldr
          There are plenty of people and code using both the Qt Designer and the QSql... classes very happily. @Denni-0 has his own opinions about this, which is fair enough, but (respectfully) they are not the mainstream/majority views. Make of that as you choose.

          I use QSqlRelationalTableModel and QDataWidgetMapper. How can I display numeric data from the database in lineedits according to my locale, with decimal comma instead of decimal point?

          Since you show it does not seem to do this left to its own devices (admittedly surprising, possibly worth a bug report), but your test code with a QLineEdit does what you want, have you seen https://doc.qt.io/qt-5/qdatawidgetmapper.html#setItemDelegate which would allow you to use your code in a delegate? I'm not sure how you would, perhaps, achieve your own widget only for numbers in a line edit while forwarding all others to the original delegate, but you could investigate.

          1 Reply Last reply
          1
          • B bkvldr

            I find Denni 0's post very interesting, but I would definitely appreciate a follow up on my original question. I would like to know if I can finish the application with my approach.

            I use QSqlRelationalTableModel and QDataWidgetMapper. How can I display numeric data from the database in lineedits according to my locale, with decimal comma instead of decimal point?

            Please see posts above.

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #10

            @bkvldr said in How to get comma as decimal separator in line edits?:

            I would like to know if I can finish the application with my approach.

            I use QSqlRelationalTableModel and QDataWidgetMapper. How can I display numeric data from the database in lineedits according to my locale, with decimal comma instead of decimal point?

            Understanding the root cause

            The behaviour that you see is caused by something a lot lower-level than QSqlRelationalTableModel and QDataWidgetMapper. It boils down to this (written in C++, but hopefully easy enough to understand for a Python developer):

            QLocale::setDefault(QLocale::Norwegian);
            
            QLineEdit le;
            le.setText( le.locale().toString(12.34) );
            // Shows "12,34"
            
            le.setText( QString::number(12.34) );
            // Shows "12.34"
            
            le.setProperty("text", 12.34);
            // Shows "12.34"
            

            QDataWidgetMapper does not know about the existence of QLineEdit. It relies on QAbstractItemDelegate to transfer data to/from widgets, and QAbstractItemDelegate in turn relies on the Qt property system to do data conversions.

            Now, QLineEdit's USER property (see https://doc.qt.io/qt-5/properties.html ) is "text", which is a QString instead of a double. Some kind of conversion is required.

            Unless the caller explicitly uses a locale-aware conversion, number-to-string conversions assume an en-US locale. See https://doc.qt.io/qt-5/qstring.html#number, for example: "The formatting always uses QLocale::C, i.e., English/UnitedStates. To get a localized string representation of a number, use QLocale::toString() with the appropriate locale."

            Solution(s)

            In a nutshell, you need to somehow invoke a locale-aware number-to-string conversion.

            As @JonB mentioned, you could implement your own QAbstractItemDelegate to do this conversion before passing a stringified number to your QLineEdit.

            Another way is to subclass QLineEdit and specialize it for numeric data:

            class NumericLineEdit : public QLineEdit
            {
                Q_OBJECT
                Q_PROPERTY(double number READ number WRITE setNumber USER true)
            
            public:
                // ...
            
                double number() const;
                void setNumber(double num); // In here, do a locale-aware conversion before calling QLineEdit::setText()
            };
            

            Yet another way is to avoid using QLineEdit and use QDoubleSpinBox instead.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            JonBJ 1 Reply Last reply
            4
            • JKSHJ JKSH

              @bkvldr said in How to get comma as decimal separator in line edits?:

              I would like to know if I can finish the application with my approach.

              I use QSqlRelationalTableModel and QDataWidgetMapper. How can I display numeric data from the database in lineedits according to my locale, with decimal comma instead of decimal point?

              Understanding the root cause

              The behaviour that you see is caused by something a lot lower-level than QSqlRelationalTableModel and QDataWidgetMapper. It boils down to this (written in C++, but hopefully easy enough to understand for a Python developer):

              QLocale::setDefault(QLocale::Norwegian);
              
              QLineEdit le;
              le.setText( le.locale().toString(12.34) );
              // Shows "12,34"
              
              le.setText( QString::number(12.34) );
              // Shows "12.34"
              
              le.setProperty("text", 12.34);
              // Shows "12.34"
              

              QDataWidgetMapper does not know about the existence of QLineEdit. It relies on QAbstractItemDelegate to transfer data to/from widgets, and QAbstractItemDelegate in turn relies on the Qt property system to do data conversions.

              Now, QLineEdit's USER property (see https://doc.qt.io/qt-5/properties.html ) is "text", which is a QString instead of a double. Some kind of conversion is required.

              Unless the caller explicitly uses a locale-aware conversion, number-to-string conversions assume an en-US locale. See https://doc.qt.io/qt-5/qstring.html#number, for example: "The formatting always uses QLocale::C, i.e., English/UnitedStates. To get a localized string representation of a number, use QLocale::toString() with the appropriate locale."

              Solution(s)

              In a nutshell, you need to somehow invoke a locale-aware number-to-string conversion.

              As @JonB mentioned, you could implement your own QAbstractItemDelegate to do this conversion before passing a stringified number to your QLineEdit.

              Another way is to subclass QLineEdit and specialize it for numeric data:

              class NumericLineEdit : public QLineEdit
              {
                  Q_OBJECT
                  Q_PROPERTY(double number READ number WRITE setNumber USER true)
              
              public:
                  // ...
              
                  double number() const;
                  void setNumber(double num); // In here, do a locale-aware conversion before calling QLineEdit::setText()
              };
              

              Yet another way is to avoid using QLineEdit and use QDoubleSpinBox instead.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #11

              @JKSH said in How to get comma as decimal separator in line edits?:

              As @JonB mentioned, you could implement your own QAbstractItemDelegate to do this conversion before passing a stringified number to your QLineEdit.

              Now you have confused me about my own earlier answer! :)

              I thought there was only QDataWidgetMapper::setItemDelegate() to affect what widget it used for everything. Now I see there is QDataWidgetMapper::addMapping() for different widget per column. Given which, subclass QLineEdit is easiest. So I don't get what the point of the setItemDelegate() is over the QDataWidgetMapper as a whole is when you can set the widget per column?

              JKSHJ 1 Reply Last reply
              0
              • JonBJ JonB

                @JKSH said in How to get comma as decimal separator in line edits?:

                As @JonB mentioned, you could implement your own QAbstractItemDelegate to do this conversion before passing a stringified number to your QLineEdit.

                Now you have confused me about my own earlier answer! :)

                I thought there was only QDataWidgetMapper::setItemDelegate() to affect what widget it used for everything. Now I see there is QDataWidgetMapper::addMapping() for different widget per column. Given which, subclass QLineEdit is easiest. So I don't get what the point of the setItemDelegate() is over the QDataWidgetMapper as a whole is when you can set the widget per column?

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #12

                @JonB said in How to get comma as decimal separator in line edits?:

                So I don't get what the point of the setItemDelegate() is over the QDataWidgetMapper as a whole is when you can set the widget per column?

                I listed 3 different ways to tackle the problem, from hardest to easiest. @bkvldr mentioned that this is a learning project, so the point here is to provide an opportunity to explore different parts of Qt. The point is not to showcase the Best Solution™.

                Given which, subclass QLineEdit is easiest.

                Actually, I'd say "use QDoubleSpinBox" is easiest.

                @Denni-0 said in How to get comma as decimal separator in line edits?:

                while the end issue might be exactly what you describe it is not the core issue. The core issue is implementing a solution as a direct from the Database into GUI process as the MVC methodology version does not have this issue because the data when presented to the GUI is in format that it can easily consume and the data when presented to the Database is in a format that it can easily consume.

                Even with the MVC methodology, we still need to be aware that certain data conversion pathways do not take the locale into account, and we must program our MVC components accordingly.

                This issue affects more than just choosing an architecture for transferring data between front-ends and back-ends. It also affects things like exporting data to CSV files; it also affects non-GUI applications.

                The key is... how can we simplify it and yet make it as smart as possible or going to the model of K.I.S.S. (Keep It Simple and Smart). I have seen programmers create nightmares by trying to get fancy and slick when something a lot simpler would have been a whole lot smarter.

                I agree with you that keeping things simple and smart is definitely desirable. What is "simplest" and "smartest" is situational though.

                If I have a whimsical boss who might suddenly demand that I replace a local native GUI with a web interface, then yes it could be smart for me to start with an ultra-flexible MVC implementation.

                However, if I know that I won't ever need to change my front-end or back-end, then using out-of-the-box components from the Qt toolkit is the simpler and smarter option because it lets me get my app working well with a lot less code.

                @JKSH the solution you propose is actually a lot more complex than it needs to be

                "Replace QLineEdit with QDoubleSpinBox" is much simpler than "Re-architect your whole program".

                BTW I did enjoy your in depth dive into this as I do enjoy having a better understanding of some of the inner workings as that in turns helps me to understand how to do things simpler and remain smart about doing it that way.

                I'm glad to hear that. Live till we're old, learn till we're old (Chinese proverb)

                If you'd like to do your own deep-dives, I highly recommend the Woboq Code Browser which lets us navigate the internals of Qt code interactively. I started here and traced the call chain to discover what was happening: https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qdatawidgetmapper.cpp.html#_ZN17QDataWidgetMapper7toFirstEv

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                JonBJ 1 Reply Last reply
                1
                • JKSHJ JKSH

                  @JonB said in How to get comma as decimal separator in line edits?:

                  So I don't get what the point of the setItemDelegate() is over the QDataWidgetMapper as a whole is when you can set the widget per column?

                  I listed 3 different ways to tackle the problem, from hardest to easiest. @bkvldr mentioned that this is a learning project, so the point here is to provide an opportunity to explore different parts of Qt. The point is not to showcase the Best Solution™.

                  Given which, subclass QLineEdit is easiest.

                  Actually, I'd say "use QDoubleSpinBox" is easiest.

                  @Denni-0 said in How to get comma as decimal separator in line edits?:

                  while the end issue might be exactly what you describe it is not the core issue. The core issue is implementing a solution as a direct from the Database into GUI process as the MVC methodology version does not have this issue because the data when presented to the GUI is in format that it can easily consume and the data when presented to the Database is in a format that it can easily consume.

                  Even with the MVC methodology, we still need to be aware that certain data conversion pathways do not take the locale into account, and we must program our MVC components accordingly.

                  This issue affects more than just choosing an architecture for transferring data between front-ends and back-ends. It also affects things like exporting data to CSV files; it also affects non-GUI applications.

                  The key is... how can we simplify it and yet make it as smart as possible or going to the model of K.I.S.S. (Keep It Simple and Smart). I have seen programmers create nightmares by trying to get fancy and slick when something a lot simpler would have been a whole lot smarter.

                  I agree with you that keeping things simple and smart is definitely desirable. What is "simplest" and "smartest" is situational though.

                  If I have a whimsical boss who might suddenly demand that I replace a local native GUI with a web interface, then yes it could be smart for me to start with an ultra-flexible MVC implementation.

                  However, if I know that I won't ever need to change my front-end or back-end, then using out-of-the-box components from the Qt toolkit is the simpler and smarter option because it lets me get my app working well with a lot less code.

                  @JKSH the solution you propose is actually a lot more complex than it needs to be

                  "Replace QLineEdit with QDoubleSpinBox" is much simpler than "Re-architect your whole program".

                  BTW I did enjoy your in depth dive into this as I do enjoy having a better understanding of some of the inner workings as that in turns helps me to understand how to do things simpler and remain smart about doing it that way.

                  I'm glad to hear that. Live till we're old, learn till we're old (Chinese proverb)

                  If you'd like to do your own deep-dives, I highly recommend the Woboq Code Browser which lets us navigate the internals of Qt code interactively. I started here and traced the call chain to discover what was happening: https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qdatawidgetmapper.cpp.html#_ZN17QDataWidgetMapper7toFirstEv

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by JonB
                  #13

                  @JKSH said in How to get comma as decimal separator in line edits?:

                  Given which, subclass QLineEdit is easiest.

                  Actually, I'd say "use QDoubleSpinBox" is easiest.

                  I meant, the easiest solution given wanting to continue with a QLineEdit-type. Just sub-classing it for (floating point) numbers is easier than writing your own delegate.

                  So I don't get what the point of the setItemDelegate() is over the QDataWidgetMapper as a whole is when you can set the widget per column?

                  My question is here is not to do with "best solution". May I try asking again, as I did not get the answer I wanted and I really would like to understand?

                  I said: at the time I recommended setItemDelegate() I did not know about addMapping(). Given that addMapping() allows the specification of individual widget types per each column, I am now asking: what is the point of setItemDelegate()? That is once per QDataWidgetMapper, not per column. I don't understand when that gets used given that you have per-column-mapped-widgets. When is it used? What is the point of one delegate across all columns when you have addMapping()? E.g. is it perhaps that the item delegate gets used if & only if you haven't specified any addMapping()s?? Or what? I have not gathered this from reading the docs. Thank you.

                  JKSHJ 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @JKSH said in How to get comma as decimal separator in line edits?:

                    Given which, subclass QLineEdit is easiest.

                    Actually, I'd say "use QDoubleSpinBox" is easiest.

                    I meant, the easiest solution given wanting to continue with a QLineEdit-type. Just sub-classing it for (floating point) numbers is easier than writing your own delegate.

                    So I don't get what the point of the setItemDelegate() is over the QDataWidgetMapper as a whole is when you can set the widget per column?

                    My question is here is not to do with "best solution". May I try asking again, as I did not get the answer I wanted and I really would like to understand?

                    I said: at the time I recommended setItemDelegate() I did not know about addMapping(). Given that addMapping() allows the specification of individual widget types per each column, I am now asking: what is the point of setItemDelegate()? That is once per QDataWidgetMapper, not per column. I don't understand when that gets used given that you have per-column-mapped-widgets. When is it used? What is the point of one delegate across all columns when you have addMapping()? E.g. is it perhaps that the item delegate gets used if & only if you haven't specified any addMapping()s?? Or what? I have not gathered this from reading the docs. Thank you.

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #14

                    @JonB said in How to get comma as decimal separator in line edits?:

                    May I try asking again, as I did not get the answer I wanted and I really would like to understand?

                    I said: at the time I recommended setItemDelegate() I did not know about addMapping().  Given that addMapping() allows the specification of individual widget types per each column, I am now asking: what is the point of setItemDelegate()?  That is once per QDataWidgetMapper, not per column.  I don't understand when that gets used given that you have per-column-mapped-widgets.  When is it used?  What is the point of one delegate across all columns when you have addMapping()?  E.g. is it perhaps that the item delegate gets used if & only if you haven't specified any addMapping()s??  Or what?  I have not gathered this from reading the docs.  Thank you.

                    Ah, I see. Sorry for misunderstanding your question.

                    First, note that QDataWidgetMapper uses delegates a bit differently from QAbstractItemView.

                    • A View asks the Delegate to create an editor widget; the Delegate can choose to create a different widget for different columns.
                    • A Mapper tells the Delegate which editor widget to use; the Delegate has no say here because the choice is set by QDataWidgetMapper::addMapping().

                    In both cases though, the Delegate is responsible for transferring/converting data between the editor widget and the model.

                    If you don't call QDataWidgetMapper::setItemDelegate(), then you're using the default Delegate (which performs non-locale-aware conversion). However, if you subclass QAbstractItemDelegate and call QDataWidgetMapper::setItemDelegate(), then you can control how the data is converted between the editor widget and the model. For example, you can reimplement QAbstractItemModel::setEditorData() and force it to do a locale-aware conversion before calling QLineEdit::setText().

                    Does this answer your question?

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    JonBJ 1 Reply Last reply
                    2
                    • JKSHJ JKSH

                      @JonB said in How to get comma as decimal separator in line edits?:

                      May I try asking again, as I did not get the answer I wanted and I really would like to understand?

                      I said: at the time I recommended setItemDelegate() I did not know about addMapping().  Given that addMapping() allows the specification of individual widget types per each column, I am now asking: what is the point of setItemDelegate()?  That is once per QDataWidgetMapper, not per column.  I don't understand when that gets used given that you have per-column-mapped-widgets.  When is it used?  What is the point of one delegate across all columns when you have addMapping()?  E.g. is it perhaps that the item delegate gets used if & only if you haven't specified any addMapping()s??  Or what?  I have not gathered this from reading the docs.  Thank you.

                      Ah, I see. Sorry for misunderstanding your question.

                      First, note that QDataWidgetMapper uses delegates a bit differently from QAbstractItemView.

                      • A View asks the Delegate to create an editor widget; the Delegate can choose to create a different widget for different columns.
                      • A Mapper tells the Delegate which editor widget to use; the Delegate has no say here because the choice is set by QDataWidgetMapper::addMapping().

                      In both cases though, the Delegate is responsible for transferring/converting data between the editor widget and the model.

                      If you don't call QDataWidgetMapper::setItemDelegate(), then you're using the default Delegate (which performs non-locale-aware conversion). However, if you subclass QAbstractItemDelegate and call QDataWidgetMapper::setItemDelegate(), then you can control how the data is converted between the editor widget and the model. For example, you can reimplement QAbstractItemModel::setEditorData() and force it to do a locale-aware conversion before calling QLineEdit::setText().

                      Does this answer your question?

                      JonBJ Online
                      JonBJ Online
                      JonB
                      wrote on last edited by JonB
                      #15

                      @JKSH
                      So the default QDataWidgetMapper::itemDelegate() has code which says "look at what column, look at the addMapping()s, and create the QWidget mapped for the column", is that right? So in the normal/this case at least, you don't tend to need to do any setItemDeletegate() of your own, you just use the supplied one and let it work off your addMappings() (where e.g. you can sub-class QLineEdit for numbers --- which to me seems the easiest without creating your own delegate), right? So if the OP uses your NumericLineEdit there is no need to fiddle with setItemDelegate() at all, you only need to in other cases?

                      JKSHJ 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @JKSH
                        So the default QDataWidgetMapper::itemDelegate() has code which says "look at what column, look at the addMapping()s, and create the QWidget mapped for the column", is that right? So in the normal/this case at least, you don't tend to need to do any setItemDeletegate() of your own, you just use the supplied one and let it work off your addMappings() (where e.g. you can sub-class QLineEdit for numbers --- which to me seems the easiest without creating your own delegate), right? So if the OP uses your NumericLineEdit there is no need to fiddle with setItemDelegate() at all, you only need to in other cases?

                        JKSHJ Offline
                        JKSHJ Offline
                        JKSH
                        Moderators
                        wrote on last edited by JKSH
                        #16

                        @JonB said in How to get comma as decimal separator in line edits?:

                        So the default QDataWidgetMapper::itemDelegate() has code which says "look at what column, look at the addMapping()s, and create the QWidget mapped for the column", is that right?

                        Nope.

                        With a Mapper, the Delegate does not create a widget; the Delegate is given the pointer to the widget it should read/write.

                        Views Mappers
                        The editor Widget is... Created by the Delegate when the View calls QAbstractItemModel::createEditor() Created by the programmer first, then specified via QDataWidgetMapper::addMapping()
                        Data is passed from the Model to the Widget when... The View calls QAbstractItemDelegate::setEditorData() The Mapper calls QAbstractItemDelegate::setEditorData()
                        Data is passed from the Widget to the Model when... The View calls QAbstractItemDelegate::setModelData() The Mapper calls QAbstractItemDelegate::setModelData()

                        So in the normal/this case at least, you don't tend to need to do any setItemDeletegate() of your own, you just use the supplied one...

                        Yep.

                        ...and let it work off your addMappings() (where e.g. you can sub-class QLineEdit for numbers --- which to me seems the easiest without creating your own delegate), right?

                        Yep.

                        So if the OP uses your NumericLineEdit there is no need to fiddle with setItemDelegate() at all, you only need to in other cases?

                        Yep.

                        In summary,

                        • QDataWidgetMapper::addMapping() determines which widget is used.
                        • QDataWidgetMapper::setItemDelegate() determines how data is transferred to/from the widget.

                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                        JonBJ 1 Reply Last reply
                        3
                        • JKSHJ JKSH

                          @JonB said in How to get comma as decimal separator in line edits?:

                          So the default QDataWidgetMapper::itemDelegate() has code which says "look at what column, look at the addMapping()s, and create the QWidget mapped for the column", is that right?

                          Nope.

                          With a Mapper, the Delegate does not create a widget; the Delegate is given the pointer to the widget it should read/write.

                          Views Mappers
                          The editor Widget is... Created by the Delegate when the View calls QAbstractItemModel::createEditor() Created by the programmer first, then specified via QDataWidgetMapper::addMapping()
                          Data is passed from the Model to the Widget when... The View calls QAbstractItemDelegate::setEditorData() The Mapper calls QAbstractItemDelegate::setEditorData()
                          Data is passed from the Widget to the Model when... The View calls QAbstractItemDelegate::setModelData() The Mapper calls QAbstractItemDelegate::setModelData()

                          So in the normal/this case at least, you don't tend to need to do any setItemDeletegate() of your own, you just use the supplied one...

                          Yep.

                          ...and let it work off your addMappings() (where e.g. you can sub-class QLineEdit for numbers --- which to me seems the easiest without creating your own delegate), right?

                          Yep.

                          So if the OP uses your NumericLineEdit there is no need to fiddle with setItemDelegate() at all, you only need to in other cases?

                          Yep.

                          In summary,

                          • QDataWidgetMapper::addMapping() determines which widget is used.
                          • QDataWidgetMapper::setItemDelegate() determines how data is transferred to/from the widget.
                          JonBJ Online
                          JonBJ Online
                          JonB
                          wrote on last edited by JonB
                          #17

                          @JKSH
                          Got it! So, as I think you said, QAbstractItemDelegate says

                          The QAbstractItemDelegate class is used to display and edit data items from a model.

                          but you're saying QDataWidgetMapper::itemDelegate() does not itself do the "display and edit data items" here, that gets done via the addMapping(). Here we only use it for its data value transfer features. Have I finally got it? Nice and confusing.... :)

                          JKSHJ 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @JKSH
                            Got it! So, as I think you said, QAbstractItemDelegate says

                            The QAbstractItemDelegate class is used to display and edit data items from a model.

                            but you're saying QDataWidgetMapper::itemDelegate() does not itself do the "display and edit data items" here, that gets done via the addMapping(). Here we only use it for its data value transfer features. Have I finally got it? Nice and confusing.... :)

                            JKSHJ Offline
                            JKSHJ Offline
                            JKSH
                            Moderators
                            wrote on last edited by
                            #18

                            @JonB said in How to get comma as decimal separator in line edits?:

                            Here we only use it for its data value transfer features. Have I finally got it?

                            That's a good summary :)

                            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                            1 Reply Last reply
                            1
                            • B Offline
                              B Offline
                              bkvldr
                              wrote on last edited by
                              #19

                              Thanks to all of you!
                              A quick test shows that the particular problem I had with the decimal separator can be solved with QDoubleSpinBox

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved