Plugin adding tabs to QtCreator


    This article describes how to add tabs to QtCreator using an extension system (plug-in) that does not require modification of the source code of QtCreator itself.

    When switching to using the QtCreator IDE, it seems unusual to have the usual tabs for open files. Over time, you get used to other means of navigating the source. QtCreator has at least six such tools:
    • it is convenient to use the F4 key to switch between .h and .cpp files;
    • all open files are displayed in the "Open Documents" panel;
    • Ctrl + Tab displays a list of all open files directly in the editing area;
    • Ctrl + K displays a list of files with filtering as you type;
    • Alt + Left allows you to navigate through the history of navigation between open files;
    • You can also navigate the project tree.

    All these methods are indispensable when editing multiple files at once. When editing a small number of sources, using tabs is, in my humble opinion, more convenient. Tabs are also favored by their widespread use in implementing the MDI (Multi Document Interface) in development environments, text editors, viewers, and browsers.

    The topic of tabs has been raised repeatedly on the forums. The developers even included the question “Why does Qt Creator not use tabs for editors?” to the FAQ list The answer to this question is as follows:
    • Tabs are not a scalable solution. They work well with 5-6 open editors, but become cumbersome with 10. With a further increase in the number of editable files, navigation with the help of tabs becomes very difficult.
    • Tabs do not adapt to your work environment settings.
    • Tabs force you to limit the number of open editors, because otherwise you start to get confused.

    So that this plugin does not go against the ideology of QtCreator, I propose to immediately limit its scope: editing a small (up to 10) number of files. The plugin, of course, allows you to open a larger number of editors, but in this case it is still better to use the QtCreator features listed at the beginning of the article.

    Key Features:
    • harmonious QSS style of tabs (tabs do not callous the eyes and eat only about 18 px);
    • QtCreator color scheme support (Tools-> Options-Environment-> General-> Color);
    • the ability to switch between 10 tabs with a key combination (Ctrl + Alt + N, where N is a key in a number row from 1 to 0). I tried to add shorter key combinations, but all of them were already “reserved”;
    • displaying tabs in all modes (Edit, Design, etc), which allows you to switch between editing the * .ui form and the file of the corresponding class in one click on the tab (or using hot keys).

    The plugin is not without flaws:
    • Currently, the plugin does not fully support split-configuration of the editor window (when the editing area is divided into several sub-areas, TabBar remains the same for everyone).

    PS Please take this small post as the announcement of another plugin. I hope it will be useful to the community of Qt-programmers.

    References:

    1. Project page on Sourceforge.net (currently not supported, for new versions of QtCreator see link 2).
    2. Fork of the developer Oleg Shparber on GitHub . The source code of the plugin working in new versions is worth looking there.

    To install the plugin, the contents of the archive must be unpacked into the directory where the plugins are located:
    for Windows, usually C: \ Qt \ Tools \ QtCreator \ lib \ qtcreator \ plugins.
    for Lunux-based systems /home/username/Qt5.2.0/Tools/QtCreator/lib/qtcreator/plugins when installing Qt in the user directory. Or (as an option) /opt/Qt5.2.0/Tools/QtCreator/lib/qtcreator/plugins (installed on Ubuntu).
    for Mac OS X / Applications / Qt Creator.app/Contents/PlugIns

    Also popular now: