0

I'm trying to convert a string into a short int by using:

short tempS = QString("%1").arg(arguement);

where argument is a QString. however I'm getting the error:

crosses initialization of short int tempS

Coding Mash
  • 3,338
  • 5
  • 24
  • 45
Amre
  • 1,630
  • 8
  • 29
  • 41

1 Answers1

1

There is a method toShort() in the QString class (doc):

short tempS = arguement.toShort();

As shown in the doc, two arguments can be specified: a reference to a boolean to check if the conversion succeeded, and the base if you want anything else than 10.

talnicolas
  • 13,885
  • 7
  • 36
  • 56