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
  • 13,645
  • 12
  • 90
  • 121

0 Answers0