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. [SOLVED] ToAscii() method in Qt5.2.1

[SOLVED] ToAscii() method in Qt5.2.1

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 8.7k 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.
  • M Offline
    M Offline
    MohammadReza
    wrote on 28 Feb 2014, 07:41 last edited by
    #1

    Hello dears.

    In Qt5.2.1,When i want to use ToAscii() for a variable of Qstring datatype, there is no suggestion in autocomplete list!
    Isn`t there this method in Qt5.2.1?

    Thanks a lot.
    Ya Ali.

    1 Reply Last reply
    1
    • J Offline
      J Offline
      Jeroentjehome
      wrote on 28 Feb 2014, 08:07 last edited by
      #2

      ToAscii might have been removed. Check out the release information of Qt5.2.1: "toAscii is obsolete!!":http://qt-project.org/doc/qt-5/qstring-obsolete.html. It is an almost useless function since it's better to use the toUtf8() function.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MohammadReza
        wrote on 28 Feb 2014, 14:25 last edited by
        #3

        Thanks For your response.
        I want to set this question "solved". I don`t know how?

        1 Reply Last reply
        0
        • B Offline
          B Offline
          BowCatShot
          wrote on 1 Mar 2014, 15:16 last edited by
          #4

          Here's what worked for me. To get a file name into an ascii string>

          QString filename = "blahblahblah";
          
          QByteArray ba = filename.toUtf8();
          const char *thefile = ba.constData();
          
          last10 = fopen(thefile,"r");
          
          1 Reply Last reply
          0
          • S Offline
            S Offline
            sierdzio
            Moderators
            wrote on 3 Mar 2014, 07:18 last edited by
            #5

            The official replacement for QString::toAscii() is QString::toLatin1(). With toUtf8() you are changing the encoding!

            (Z(:^

            1 Reply Last reply
            0
            • A Offline
              A Offline
              amahta
              wrote on 3 Mar 2014, 08:58 last edited by
              #6

              just like sierdzio said, it's QString::toLatin1()
              To make this solved just append [SOLVED] to the title of the thread

              Thou shalt programme
              http://www.amin-ahmadi.com

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jeroentjehome
                wrote on 3 Mar 2014, 09:11 last edited by
                #7

                Ah, yes, your right. toLatin1() is the correct way.
                To mark as [SOLVED] there is in your first post (just below your picture) a green 'edit'. Click that and your able to change your post.

                Greetz, Jeroen

                1 Reply Last reply
                0

                1/7

                28 Feb 2014, 07:41

                • Login

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