I solved by myself, maybe.
In the constructor of TextEdit,
after
textEdit = new QTextEdit(this);
add
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
then I could save .md file as encoded by UTF-8.
Without this, .md file will be saves as shift-jis (system's default).
.txt files are always saved using UTF-8 encoding without the added line.