Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Cut and paste in QPlainTextEdit



  • I have set the font of a QPlainTextEdit to Courier New:

    @ QFont font = QFont("Courier New");
    font.setPixelSize(14);
    charFormat = new QTextCharFormat();
    charFormat->setFont(font);
    setCurrentCharFormat(*charFormat);@

    When I cut and paste part of a text this is going fine.
    However, when I select all, cut and paste the font is not Courier New anymore.

    What is the problem and how can this be solved?
    [edit: Code highlighting / Vass]



  • You should call setFont(font) on the QPlainTextEdit.

    Could you please wrap your code in two @-Tags, this makes it more readable.


Log in to reply