Qt Creator plugin - how to hide output panes
-
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. -
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.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).
-
Wow, I didn't know about this.
It works well for me need.
Thank you. -
S SebastianM has marked this topic as solved
-
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 checkcmd->action()->isChecked()to make choice when to hide or show. In Lua actions I see only triggering action, not checking action or command state. -
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. -
Thank you.
That covers caseaction.setChecked("QtCreator.ToggleLeftSidebar", false)- so I can hide sidebars.
Similary withaction.setChecked(""QtCreator.Modes.IconsOnly", true).