I have a basic quetion.
I would change the font family of a QTextEdit by means of the following code:

void Window::chooseFont()
{
bool ok;
QFont initial("Times New Roman", 48);
QFont font = QFontDialog::getFont(&ok, initial, this);

if (ok) {
QTextCharFormat format;
format.setFont(font);
txt->mergeCurrentCharFormat(format);


}

}


The strange thing is that I get changed the text if and only if I make a selection inside txt. i.e. the character format does not change if a continue to edit on the right of the current cursor position.
Any help appreciated