Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] QTextStream \n does not function
Qt 6.11 is out! See what's new in the release blog

[solved] QTextStream \n does not function

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 7 Posters 6.3k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    @
    QFile file_datiGenerali("C:/TemperamentvolleSMS/datiGenerali.txt");
    if(file_datiGenerali.open(QIODevice::Append | QIODevice::ReadWrite))
    {
    QTextStream stream_fileDatiGenerali(&file_datiGenerali);
    qDebug() << "i am in importasms";
    stream_fileDatiGenerali.setCodec("UTF-8");
    stream_fileDatiGenerali << "USATO GIA<br>";
    stream_fileDatiGenerali << "ciao";
    this->visualizzaSchermataBase();
    }
    @
    does not start.
    i tried too:
    @
    stream_fileDatiGenerali << "USATO GIA\n";
    stream_fileDatiGenerali << "ciao";

        stream_fileDatiGenerali << "USATO GIA" << endl;
        stream_fileDatiGenerali << "ciao";
    
        stream_fileDatiGenerali << "USATO GIA" << '\n';
        stream_fileDatiGenerali << "ciao";
    

    @
    nothing...

    Edit: fixed spelling mistake in title; Andre

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      do you get the "i am in importasms" output?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rahul Das
        wrote on last edited by
        #3

        bq. QFile file_datiGenerali("C:/TemperamentvolleSMS/datiGenerali.txt");

        Are you sure with the slashes ;) ??


        Declaration of (Platform) independence.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          [quote author="Rahul Das" date="1314188375"]bq. QFile file_datiGenerali("C:/TemperamentvolleSMS/datiGenerali.txt");

          Are you sure with the slashes ;) ??[/quote]
          Yes. That is correct, and the recommended way of dealing with file paths. Internally, use forward slashes, only convert to the native format when presenting to the user. Qt will handle the slashes just fine.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rahul Das
            wrote on last edited by
            #5

            Oh ok! Thank you Andre. That something new to me.


            Declaration of (Platform) independence.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Try adding the QIODevice::Text flag

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                You should tell us, what you do expect to be in the file, and what does it actually contain. Probably using some hexdump utility to show the actual bytes.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  bq. what you do expect to be in the file
                  i want it comes so:
                  "USATO GIA
                  ciao".

                  bq. do you get the “i am in importasms” output?

                  i get “i am in importasms” output.

                  bq. what does it actually contain

                  i create the file

                  i will use the app on device n c5-03!

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mlong
                    wrote on last edited by
                    #9

                    So what is the output of the file that gets written?

                    Software Engineer
                    My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      bq. by octal Try adding the QIODevice::Text flag

                      this was the solution (windows 7)

                      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