I make a text editor. Here is a project on github

there is all the code. The errors are implicit (everything is compiled), but changing the font and the "save" button do not work. Help fix bugs, thanks.

Add button code save

void MainClass::slotSaveClicked(){ QTextDocumentWriter writer; writer.setFormat("odf"); writer.setFileName("output.odf"); writer.write (MainTextEdit->document()); } 

And QFontComboBox slot

 void MainClass::setTextEditFont(){ QFont font = FStyleList->currentFont(); font.setPixelSize( FontsizeSpin -> value()); if (ItalyStyle->isChanged()){ font.setItalic(true); } else if (BoldStyle->isChecked()){ font.setBold(true); } else if (UnderLineStyle->isChecked()){ font.setUnderline(true); } MainTextEdit->setFont(font); } 

Closed due to the fact that the essence of the question is unclear by the participants Igor , Kromster , freim , LFC , 0xdb on March 27 at 17:53 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • The link does not work, 404. Yes, and I doubt that someone will bother ... - HolyBlackCat
  • Show the font change code and save buttons. - Insider
  • Did zhezh already) What does not work there again? - Alexander Chernin
  • How do you have a compiler that skips ItalyStyle->isChanged() ? - Alexander Chernin
  • Do not miss. This is an old version of the project. - Konstantin_SH

1 answer 1

To change the font, use the following

 MainTextEdit->setFont(QFont("Courier", 9)); 

To save files

 void MyClass::write(QByteArray data) { QFile file("out.txt"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return; QTextStream out(&file); out.write(data); file.close(); }