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. ToInt() doesn't work...
Forum Updated to NodeBB v4.3 + New Features

ToInt() doesn't work...

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.7k 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.
  • T Offline
    T Offline
    ThaRez
    wrote on last edited by
    #1

    Hello
    I'm reading a string that contains a number and a "Z" letter. I'm removing the "Z" and converting the string to int...But it doesnt work...

    @milliSec = milliSec.remove(QChar('Z'), Qt::CaseSensitive);
    qDebug() << "MILLISECONDS1: " << milliSec;
    milliSec = milliSec.toInt();
    qDebug() << "MILLISECONDS2: " << milliSec;@

    MILLISECONDS1 print the number correctly, but 2 doesn't (string 456375Z):

    MILLISECONDS2: "456375"
    MILLISECONDS2: "·"

    Any suggestions? Thanks
    Richard

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nosf
      wrote on last edited by
      #2

      Are you sure youve named your variables correct?

      Your string and int seem to have the same name...try this

      @ milliSec = milliSec.remove(QChar('Z'), Qt::CaseSensitive);
      qDebug() << "MILLISECONDS1: " << milliSec;
      int result(milliSec.toInt());
      qDebug() << "Int Value: " << result;@

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        Of which type is milliSec?

        http://www.catb.org/~esr/faqs/smart-questions.html

        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