Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. To save the contents displayed in QsciScintilla into a text file
Qt 6.11 is out! See what's new in the release blog

To save the contents displayed in QsciScintilla into a text file

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I know this is not a QsciScintilla forum , some help will be helpful
    I am using an object of QsciScintilla object and using following code to load the file.

    class myEdit:public QsciScintilla{
    public:
    void readFile();
    };

    myEdit::readFile() {
    if (FILE* fp = fopen(ofilename.toLatin1(), "r")) {
    QTextStream ms(fp, QIODevice::ReadOnly);
    int bufferSize =(1024* 1024);
    while(!ms.atEnd() {
    QString s = ms.read(bufferSize);
    append(s);
    }
    }
    }
    I want to save contents of the Editor into an text file so that I use the same for regressions. Can some one guide me , how to save the contents of the Editor into a text file

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      It seems you can get the text with
      QString QsciScintilla::text ()
      and then you can just save that.

      1 Reply Last reply
      2
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        Super easy!

        myEdit::writeFile() {
        QFile destination("destination.txt");
        if (destination.open(QIODevice::WriteOnly)) {
        QTextStream ms(&destination);
        ms << text();
        }
        }
        

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved