Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator plugin - how to hide output panes
Forum Updated to NodeBB v4.3 + New Features

Qt Creator plugin - how to hide output panes

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 2 Posters 280 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.
  • SebastianMS Offline
    SebastianMS Offline
    SebastianM
    wrote last edited by SebastianM
    #1

    Qt Creator 18, MSVC 2022, QT 6.10, Windows 10

    I'm developing plugin.
    I would like to hide or show bottom output pane.
    Working solution is to use CommandIDs.

    #include <coreplugin/actionmanager/actionmanager.h>
    #include <coreplugin/actionmanager/command.h>
    
    void YourPlugin::hideAllOutputPanes()
    {
        // Hide common built-in panes by their Command IDs
        QStringList paneCommands = {
            "QtCreator.Pane.Issues",
            "QtCreator.Pane.ApplicationOutput",
            "QtCreator.Pane.CompileOutput",
            "QtCreator.Pane.SearchResults",
            "QtCreator.Pane.TestResults",
            "QtCreator.Pane.GeneralMessages"
        };
    
        for (const QString &id : paneCommands) {
            Core::Command *cmd = Core::ActionManager::command(Utils::Id::fromString(id));
            if (cmd && cmd->action() && cmd->action()->isChecked()) {
                // Trigger to toggle/hide the pane
                cmd->action()->trigger();
            }
        }
    }
    

    Is there better way?
    I see that output pane manager is internal class and doesn't provide official API. Using it is risky.

    M 1 Reply Last reply
    0
    • SebastianMS SebastianM

      Qt Creator 18, MSVC 2022, QT 6.10, Windows 10

      I'm developing plugin.
      I would like to hide or show bottom output pane.
      Working solution is to use CommandIDs.

      #include <coreplugin/actionmanager/actionmanager.h>
      #include <coreplugin/actionmanager/command.h>
      
      void YourPlugin::hideAllOutputPanes()
      {
          // Hide common built-in panes by their Command IDs
          QStringList paneCommands = {
              "QtCreator.Pane.Issues",
              "QtCreator.Pane.ApplicationOutput",
              "QtCreator.Pane.CompileOutput",
              "QtCreator.Pane.SearchResults",
              "QtCreator.Pane.TestResults",
              "QtCreator.Pane.GeneralMessages"
          };
      
          for (const QString &id : paneCommands) {
              Core::Command *cmd = Core::ActionManager::command(Utils::Id::fromString(id));
              if (cmd && cmd->action() && cmd->action()->isChecked()) {
                  // Trigger to toggle/hide the pane
                  cmd->action()->trigger();
              }
          }
      }
      

      Is there better way?
      I see that output pane manager is internal class and doesn't provide official API. Using it is risky.

      M Offline
      M Offline
      Marcus Tillmanns
      wrote last edited by
      #2

      You don't need to write a full plugin for this these days. You can write a (Lua) Script via "Tools => Scripting => New Script" with the following code:

      A = require'Action'
      --- Open any pane
      A.trigger("QtCreator.Pane.Issues")
      --- Switch to the general messages pane
      A.trigger("QtCreator.Pane.GeneralMessages")
      --- Close the pane
      A.trigger("QtCreator.Pane.GeneralMessages")
      

      Once saved, you can bind it to a shortcut as well (e.g. if you call it "hide-all-panes.lua", there will be an Action "Lua.Scripts.hide-all-panes" to trigger it).

      1 Reply Last reply
      4
      • SebastianMS Offline
        SebastianMS Offline
        SebastianM
        wrote last edited by SebastianM
        #3

        Wow, I didn't know about this.
        It works well for me need.
        Thank you.

        1 Reply Last reply
        0
        • SebastianMS SebastianM has marked this topic as solved
        • SebastianMS Offline
          SebastianMS Offline
          SebastianM
          wrote last edited by
          #4

          Do you know @Marcus-Tillmanns how to ensure that Left/Right sidebar is hidden?
          Action QtCreator.ToggleLeftSidebar - as name suggest - will change from hidden to visible and vice-verse.
          In C++ I can check cmd->action()->isChecked() to make choice when to hide or show. In Lua actions I see only triggering action, not checking action or command state.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Marcus Tillmanns
            wrote last edited by
            #5

            There is no way to do that at the moment. I've added a new "setChecked" function here: https://codereview.qt-project.org/c/qt-creator/qt-creator/+/698994
            Feel free to comment or suggest other functions as well.

            1 Reply Last reply
            1
            • SebastianMS Offline
              SebastianMS Offline
              SebastianM
              wrote last edited by
              #6

              Thank you.
              That covers case action.setChecked("QtCreator.ToggleLeftSidebar", false) - so I can hide sidebars.
              Similary with action.setChecked(""QtCreator.Modes.IconsOnly", true).

              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