Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Question about manipulating single facets of QLocale

Question about manipulating single facets of QLocale

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 905 Views 1 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.
  • D Offline
    D Offline
    dewi 0
    wrote on last edited by
    #1

    Hi all,
    the following code is working:

    struct comma_separator : std::numpunct<char> {
        virtual char do_decimal_point() const override { return '#'; }
    };
    
    int main(int argc, char *argv[])
    {
        const double number = 1000.25;
    
            std::cout << number;
            std::cout.imbue(std::locale(std::cout.getloc(), new comma_separator));
            std::cout << "\"different\" locale: " << number << '\n';
    }
    

    How can I get this work with QTextStream ?

    Please no answers containing references to the QLocale::toXXX methods.
    I just want to change the behaviour of a QTextStream.

    Thanks and have fun
    Norbert

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      QTextStream uses QLocale internally to determine the decimal separator so I can't see any way you can do what you are asking. sorry

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      D 1 Reply Last reply
      2
      • VRoninV VRonin

        QTextStream uses QLocale internally to determine the decimal separator so I can't see any way you can do what you are asking. sorry

        D Offline
        D Offline
        dewi 0
        wrote on last edited by
        #3

        @VRonin Can it bee that I have been so unclear ?
        If I ask for a way to get the code (which mainpulates the std::locale object of cout (which is a stream by the way )) working with QTextStream, it should be evident, that I have to maipulate the QLocale Object which is used by QTextStream. So the answer is: because I want to manipulate the Qlocale used by QTextStream.

        Any answer which will help me will be appriciated.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Please watch the tone you use when answering. Being aggressive with people taking time to help you is not a good idea.

          As it is, QLocale doesn't provide the equivalent of std::locale's facets thus @VRonin is right, you can't do what you want without going down modifying Qt's internals.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

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