The following code will in most likely cause your application to crash:
char * str1 = Q_date.toAscii().constData();
swap( str1[0], str1[2] );
char * str1 = Q_date.toAscii().constData();
swap( str1[0], str1[2] );
To copy to clipboard, switch view to plain text mode
and even if it doesn't it won't work.
You shouldn't save a pointer to the temporary object returned by toAscii(), it goes out of scope immediately. Go with Wysota's suggestion.
@jpn + wysota: It's an interesting side effect of Qt's trick with QCharRef that swap doesn't work as expected. I think they should mention QCharRef in the documentation and that it's sometimes more efficient(in this case necessary) to work on the raw QChar array returned by data()
Bookmarks