c++ - Why can't I use QString::arg function here? -


you know everywhere need qstring object parameter can use c style strings . example showmessage function needs qstring. passed c-style string function , every thing ok. mean here can think of "%1 sample text" qstring object! maybe!

statusbar()->showmessage("%1 sample text"); 

but why can't use code:

statusbar()->showmessage("%1 sample text".arg("this ")); 

because implicit-conversion qstring used, when passed const char[] function , there no implicit-conversion, without call function, so, trying call method arg on const char[], incorrect, construct qstring by

statusbar()->showmessage(qstring("%1 sample text").arg("this ")); 

and fine.


Comments