Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qt Creator Plugin: How to edit opened files
Forum Updated to NodeBB v4.3 + New Features

Qt Creator Plugin: How to edit opened files

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 2.8k Views 1 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.
  • C Offline
    C Offline
    Code_ReaQtor
    wrote on last edited by
    #1

    Greetings!

    I started a simple plugin for Qt Creator which adds/modifies specific "lines" within files opened by Creator. I was able to list files using the ProjectExplorerPlugin but I resorted to using QFile to open and edit these files. Though the code is working, a dialog box pop-ups which says that "The file untitled.pro has changed outside Qt Creator. Do you want to reload it?"

    Is there a better and cleaner way to edit opened files in Qt Creator? Can you please show example codes?

    Thanks and more powers!

    Please visit my open-source projects at https://github.com/Code-ReaQtor.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      QFile opens files on the hard drive. If you modify that, Creator detects that the file has changed on disk and pops up a window asking what to do: Reload the file from disk, ignore the changes on disk, etc.

      QFile obviously does not get you access to the piece of memory that holds the contents of that opened file in Creator which is displayed in the editors. Use the editormanager to get to the editors.

      Code is readily available in Qt Creator, we do that all over the place. Just search for usages of the specific methods of the editor manager you need examples for. To open the editor manager class without knowing the file name: Type Ctrl-K and then "c EditorManager" to jump straight to that class.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Code_ReaQtor
        wrote on last edited by
        #3

        @Tobias
        I am able to open the "file" using Core::EditorManager and Core::IEditor

        The problem is how do i read and write into the file, specifically, "line by line". Unfortunately, Ctrl-K doesn't direct me to EditorManager class so i used this "link":http://doc.qt.digia.com/qtcreator-extending/core-editormanager.html as a reference.

        My target is reading and writing line by line and append some "code" if the keyword I am looking for doesn't exist. If the keyword exists, delete or modify it. Sorry but there is very less entry/guide in the documentation. So I would be grateful for some help.

        Thanks

        Please visit my open-source projects at https://github.com/Code-ReaQtor.

        1 Reply Last reply
        0

        • Login

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