Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Indice QStringList
Forum Updated to NodeBB v4.3 + New Features

Indice QStringList

Scheduled Pinned Locked Moved Solved Italian
6 Posts 3 Posters 966 Views
  • 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.
  • PollyP Offline
    PollyP Offline
    Polly
    wrote on last edited by
    #1

    Ho un problema, in un programma la pressione di un pulsante , lo slot deve trasferire il contenuto di una QStringList in un QTextStream; ma provando mi è capitato di premere due volte il tasto e il programma è cresciato. Sicchè attraverso un lento lavoro di Debug ho visto che l'indice che attraversa la QStringList mi dà valore -1; al che penso sia vuota la QStringList, ma la funzione isEmpty, mi dà esito negativo (false). Da qui la mia domanda: l'indice è in una posizione per cui non può ripercorrere la QStringList ? Se si come posso riposizionarlo per fargli rifare il ciclo for? Oppure si è creata una nuova situazione per cui devo ragionare diversamente ?
    All'incirca lo slot è così

    QTextStream flusso;
    QStringList lista;
    Class::StreamDati_onClicked()
    {
      for (int = 0; int < lista.size() ; int++
               {
                  flusso << lista.at(i)
                }
    
    
    //your code here
    
    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      prova:

      for(const QString& i : qAsConst(lista))
      flusso << i;
      

      "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

      1 Reply Last reply
      1
      • PollyP Offline
        PollyP Offline
        Polly
        wrote on last edited by
        #3

        Si va bene, ma purtroppo fa ancora crash.

        1 Reply Last reply
        0
        • Pradeep P NP Offline
          Pradeep P NP Offline
          Pradeep P N
          wrote on last edited by
          #4

          Hi @Polly

          Can you please share some more information ? I Suspect the QStringList you are missing something.

          test.h

          private:
          
              QTextStream m_flusso;
              QStringList m_lista;
          

          test.cpp

          void Widget::on_myButton_clicked()
          {
              qDebug() << Q_FUNC_INFO << endl;
          
              for (int i = 0; i < m_lista.size() ; i++) {
                  m_flusso << m_lista.at(i);
              }
          
              qDebug() << m_flusso.readAll() << endl;
          }
          

          As my QStringList is empty the output is:

          void Widget::on_myButton_clicked()  // Q_FUNC_INFO
          
          QTextStream: No device
          "" 
          

          Can you please tell me what is your QStringList contents are, so i can help you.

          All the best.

          Pradeep Nimbalkar.
          Upvote the answer(s) that helped you to solve the issue...
          Keep code clean.

          1 Reply Last reply
          2
          • PollyP Offline
            PollyP Offline
            Polly
            wrote on last edited by
            #5

            You are right. I wrong QStringList was empty after stream.
            So i put in the begin a condition to avoid to continue to process it.
            Thx for all.

            Avevi regione. Ho sbagliato a interpretare la QStringList era vuota dopo lo stream.
            Così ho posto una condizione all'inizio per evitare che fosse riprocessata.
            Grazie per tutto,

            1 Reply Last reply
            0
            • Pradeep P NP Offline
              Pradeep P NP Offline
              Pradeep P N
              wrote on last edited by
              #6

              @Polly
              Cool, can you please mark it as SOLVED if the issue is resolved ?

              All the best.

              Pradeep Nimbalkar.
              Upvote the answer(s) that helped you to solve the issue...
              Keep code clean.

              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