0

I need to convert QString to const char* then have to pass to another function

My code looks,

QString port = "1234";
const char *Port = port.toLatin1().data();
setport(Port); //function call

Function

void setport(const char *Port){
  int p = atoi(Port); // here I am getting 0 instead 1234
}

I am using Qt5.4.1

Any help will be appreciated.

Thanks Haris

Haris
  • 12,990
  • 10
  • 84
  • 116

0 Answers0