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. macOS - QString doesn't perform properly
Forum Updated to NodeBB v4.3 + New Features

macOS - QString doesn't perform properly

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 290 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.
  • artwawA Offline
    artwawA Offline
    artwaw
    wrote on last edited by artwaw
    #1

    Hi,
    I have a bit of an issue with QString - its split() and section() methods always return empty QStringList() ro QString(). Same code ported to Windows works.
    Any hints please?

    Edit - code sample:

     QString formatter2=settings.value("archivedLabels").toString().section('_',0);
    

    or

     QString formatter2=settings.value("archivedLabels").toString().split('_').at(0);
    

    I also tried to replace QString formatter2 with QStringList() making this

    QStringList temp=settings.value("archivedLabels").toString().split('_');
    

    and got empty QStringList.

    For more information please re-read.

    Kind Regards,
    Artur

    J.HilkJ 1 Reply Last reply
    0
    • artwawA artwaw

      @J-Hilk RM_dd-MM-yyyy

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by J.Hilk
      #4

      @artwaw can't confirm that, you'll have to show us the code, that you're using

      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QString testString("RM_dd-MM-yyyy");
      
          QStringList splittedList1 = testString.split(QChar('-'));
          QStringList splittedList2 = testString.split(QChar('_'));
      
          QString section1 = testString.section(QChar('-'), 0,0);
          QString section2 = testString.section(QChar('-'), 1,1);
      
          qDebug() << splittedList1 << endl
                   << splittedList2 << endl
                   << section1 << section2;
      
          return  a.exec();
      }
      
      

      results in:
      7fe266a3-7048-44f8-973d-13809b6bb609-image.png


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      artwawA 1 Reply Last reply
      2
      • artwawA artwaw

        Hi,
        I have a bit of an issue with QString - its split() and section() methods always return empty QStringList() ro QString(). Same code ported to Windows works.
        Any hints please?

        Edit - code sample:

         QString formatter2=settings.value("archivedLabels").toString().section('_',0);
        

        or

         QString formatter2=settings.value("archivedLabels").toString().split('_').at(0);
        

        I also tried to replace QString formatter2 with QStringList() making this

        QStringList temp=settings.value("archivedLabels").toString().split('_');
        

        and got empty QStringList.

        J.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on last edited by
        #2

        @artwaw
        can you provide an example string?


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        artwawA 1 Reply Last reply
        1
        • J.HilkJ J.Hilk

          @artwaw
          can you provide an example string?

          artwawA Offline
          artwawA Offline
          artwaw
          wrote on last edited by
          #3

          @J-Hilk RM_dd-MM-yyyy

          For more information please re-read.

          Kind Regards,
          Artur

          J.HilkJ 1 Reply Last reply
          0
          • artwawA artwaw

            @J-Hilk RM_dd-MM-yyyy

            J.HilkJ Online
            J.HilkJ Online
            J.Hilk
            Moderators
            wrote on last edited by J.Hilk
            #4

            @artwaw can't confirm that, you'll have to show us the code, that you're using

            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
            
                QString testString("RM_dd-MM-yyyy");
            
                QStringList splittedList1 = testString.split(QChar('-'));
                QStringList splittedList2 = testString.split(QChar('_'));
            
                QString section1 = testString.section(QChar('-'), 0,0);
                QString section2 = testString.section(QChar('-'), 1,1);
            
                qDebug() << splittedList1 << endl
                         << splittedList2 << endl
                         << section1 << section2;
            
                return  a.exec();
            }
            
            

            results in:
            7fe266a3-7048-44f8-973d-13809b6bb609-image.png


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            artwawA 1 Reply Last reply
            2
            • J.HilkJ J.Hilk

              @artwaw can't confirm that, you'll have to show us the code, that you're using

              int main(int argc, char *argv[])
              {
                  QApplication a(argc, argv);
              
                  QString testString("RM_dd-MM-yyyy");
              
                  QStringList splittedList1 = testString.split(QChar('-'));
                  QStringList splittedList2 = testString.split(QChar('_'));
              
                  QString section1 = testString.section(QChar('-'), 0,0);
                  QString section2 = testString.section(QChar('-'), 1,1);
              
                  qDebug() << splittedList1 << endl
                           << splittedList2 << endl
                           << section1 << section2;
              
                  return  a.exec();
              }
              
              

              results in:
              7fe266a3-7048-44f8-973d-13809b6bb609-image.png

              artwawA Offline
              artwawA Offline
              artwaw
              wrote on last edited by
              #5

              @J-Hilk Then it must be me or something in my setup. Thank you!

              For more information please re-read.

              Kind Regards,
              Artur

              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