Git Product home page Git Product logo

texteditor_qtcreator's Introduction

TextEditor_QTCreator

How to run code

  1. Select File > Open File or Project (Ctrl+O or Cmd+O on macOS)
  2. 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).
  3. In the Configure Project tab, select kits for building and running your project.
  4. Select Configure Project.
  5. Try Running the code {Ctrl+R}

What has been done

  • Added basic functionalities of a text editor

    1. New File

      • Setting current text to an empty string
        ui->textEdit->setPlainText("");
    2. 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);
    3. Save

      • Setting out stream of file to save

        QTextStream out(&sFile);
        
        out << ui->textEdit->toPlainText();
        
        sFile.flush();
        sFile.close();
    4. Save As

      • Asking for a file name in a dialog box
        QString file = QFileDialog::getSaveFileName(this,"Open a file");
    5. Copy

      ui->textEdit->copy();
    6. Cut

      ui->textEdit->cut();
    7. Paste

      ui->textEdit->paste();
    8. Undo

      ui->textEdit->undo();
    9. Redo

      ui->textEdit->redo();
    10. 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);
      }
      
    11. 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);
      }

Issues / Challenges

  • 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 than mergeCharFormat.

  • Challenge 1 : Adding my Resume is bit challenging now but still finding a way to do that.

texteditor_qtcreator's People

Contributors

nishantwankhade avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.