- Select File > Open File or Project (Ctrl+O or Cmd+O on macOS)
- Select the project file for the project to open: .pro (qmake), CMakeLists.txt (CMake), .qbs (Qbs), meson.build (Meson), pyproject (Python), or Makefile.am (Autotools, experimental).
- In the Configure Project tab, select kits for building and running your project.
- Select Configure Project.
- Try Running the code {Ctrl+R}
-
Added basic functionalities of a text editor
-
New File
- Setting current text to an empty string
ui->textEdit->setPlainText("");
- Setting current text to an empty string
-
Open File
-
Asking for file name using dialog box
QFileDialog::getOpenFileName(this,"Open a file");
-
Setting Global File name to selected file
mFilename = file; // Taking all data into a in stream QTextStream in(&sFile); //Reading that data QString text = in.readAll(); sFile.close(); //Setting the read data to text ui->textEdit->setPlainText(text);
-
-
Save
-
Setting out stream of file to save
QTextStream out(&sFile); out << ui->textEdit->toPlainText(); sFile.flush(); sFile.close();
-
-
Save As
- Asking for a file name in a dialog box
QString file = QFileDialog::getSaveFileName(this,"Open a file");
- Asking for a file name in a dialog box
-
Copy
ui->textEdit->copy();
-
Cut
ui->textEdit->cut();
-
Paste
ui->textEdit->paste();
-
Undo
ui->textEdit->undo();
-
Redo
ui->textEdit->redo();
-
Bold
// Saving font weight in a local varaible int font = ui->textEdit->fontWeight(); //First check if the font weight is not equal to the weight of BOLD if(font != QFont::Bold){ // Then set the selected text to bold ui->textEdit->setFontWeight(QFont::Bold); } // If it is equal else{ // If it is equal then set text to normal {UnBold feature} ui->textEdit->setFontWeight(QFont::Normal); }
-
SubScript and SubScript
//Added scripting to a local variable //And then setting that formatting with the current format auto isSubscript = ui->textEdit->currentCharFormat(); // Will check whether the current format is subscript if(isSubscript.verticalAlignment() != QTextCharFormat::AlignSubScript){ // no // turn current format to subscript QTextCharFormat format; format.setVerticalAlignment(QTextCharFormat::AlignSubScript); ui->textEdit->setCurrentCharFormat(format); } else{ // yes // turn current format back to normal QTextCharFormat format; format.setVerticalAlignment(QTextCharFormat::AlignNormal); ui->textEdit->setCurrentCharFormat(format); } //---------------------------------------------------------------- // Similar to subscript // Current format will change auto isSubscript = ui->textEdit->currentCharFormat(); if(isSubscript.verticalAlignment() != QTextCharFormat::AlignSuperScript){ QTextCharFormat format; format.setVerticalAlignment(QTextCharFormat::AlignSuperScript); ui->textEdit->setCurrentCharFormat(format); } else{ QTextCharFormat format; format.setVerticalAlignment(QTextCharFormat::AlignNormal); ui->textEdit->setCurrentCharFormat(format); }
-
-
Issue 1 : Adding QPdfView library giving error of not finding the library.
-
Issue 2 : Current format is changed while using Bold, SubScript, SuperScript, Selected text may not change because,
setCurrentCharFormat
is used rather thanmergeCharFormat
. -
Challenge 1 : Adding my Resume is bit challenging now but still finding a way to do that.