How to copy N characters from strings to QString without using loops?

  • one
    str [size] = 0x00, then feel free to assign it in a QString. No cycles! - Vladimir Martyanov
  • you can copy everything, and then through the left - Grundy
  • In short, RTFM :) - 伪位蔚蠂慰位蠀蟿

2 answers 2

 auto qs = QString::fromLatin1(cstr, N); 
     const char* cStr = "Hello world!"; int N = 5; QString qStr(QLatin1String(cStr , N));