Creating the concrete main window with items.
-
Hello!
I want to create the concrete Qt main window filled by items.
There is a part of the main window of a some program.
When I choose the menu "View" and press on the action "Side Pane"
then a side pane appers.
As you can see that side pane has two tabs: a first tab shows the file system and a second tab shows current opened tabs with text editors.
When I press on the action "Side Pane" at the second time then that pane disappears.
I have the next questions:
- Help me to create the "Side Pane". How can I make this? And how to insert there tabs with the file system and with current opened text editors?
- The last picture has a status bar with some text in the right part and with tabs "Plain Text" and "Tab Width". How to create such tabs on that status bar?
Thank You.
-
Hello!
I want to create the concrete Qt main window filled by items.
There is a part of the main window of a some program.
When I choose the menu "View" and press on the action "Side Pane"
then a side pane appers.
As you can see that side pane has two tabs: a first tab shows the file system and a second tab shows current opened tabs with text editors.
When I press on the action "Side Pane" at the second time then that pane disappears.
I have the next questions:
- Help me to create the "Side Pane". How can I make this? And how to insert there tabs with the file system and with current opened text editors?
- The last picture has a status bar with some text in the right part and with tabs "Plain Text" and "Tab Width". How to create such tabs on that status bar?
Thank You.
Hi and welcome to the forums
1
Well you would use layouts and TabWidget.
And then code the logic to expand the SideBar area. when it should be shown.
Maybe this can be the inspiration.
https://github.com/chrisaverage/burger-menu2
You can use
https://doc.qt.io/qt-5/qstatusbar.html
and its
https://doc.qt.io/qt-5/qstatusbar.html#addWidget
with https://doc.qt.io/qt-5/qtabbar.html
to make something like that. -
Hi and welcome to the forums
1
Well you would use layouts and TabWidget.
And then code the logic to expand the SideBar area. when it should be shown.
Maybe this can be the inspiration.
https://github.com/chrisaverage/burger-menu2
You can use
https://doc.qt.io/qt-5/qstatusbar.html
and its
https://doc.qt.io/qt-5/qstatusbar.html#addWidget
with https://doc.qt.io/qt-5/qtabbar.html
to make something like that.@mrjj Hello!
I have watched the links you have offered and I can say only they don't correspond to that I want. Unfortunately but it is so.
Can I use QStackedWidget or QSplitter instead of any layouts?
How is about the content filling the side pane: the file system and an amount of opened empty tabs inserted into two tabs?
-
@mrjj Hello!
I have watched the links you have offered and I can say only they don't correspond to that I want. Unfortunately but it is so.
Can I use QStackedWidget or QSplitter instead of any layouts?
How is about the content filling the side pane: the file system and an amount of opened empty tabs inserted into two tabs?
Hello
Well Stacked is good with any concept of pages. It can take the role of a TabWQidget if
you provide the means of navigation.And yes, a splitter can be used To Allow resize the "Sidebar"
Note that a splitter is also a layout.But you should use layout internally in the Stacked if you wish the elements should follow the size of the stacked.
Layouts are used most of the time to make the app able to scale to different screens. -
Hello
Well Stacked is good with any concept of pages. It can take the role of a TabWQidget if
you provide the means of navigation.And yes, a splitter can be used To Allow resize the "Sidebar"
Note that a splitter is also a layout.But you should use layout internally in the Stacked if you wish the elements should follow the size of the stacked.
Layouts are used most of the time to make the app able to scale to different screens.I have watched the links you have offered and I can say only they don't correspond to that I want. Unfortunately but it is so.
How is about the content filling the side pane: the file system and an amount of opened empty tabs inserted into two tabs?
-
Hello!
I want to create the concrete Qt main window filled by items.
There is a part of the main window of a some program.
When I choose the menu "View" and press on the action "Side Pane"
then a side pane appers.
As you can see that side pane has two tabs: a first tab shows the file system and a second tab shows current opened tabs with text editors.
When I press on the action "Side Pane" at the second time then that pane disappears.
I have the next questions:
- Help me to create the "Side Pane". How can I make this? And how to insert there tabs with the file system and with current opened text editors?
- The last picture has a status bar with some text in the right part and with tabs "Plain Text" and "Tab Width". How to create such tabs on that status bar?
Thank You.
@Vadim-Chernetsov It looks like a classic QMainWindow + QDockWidget layout. Here's something that does more or less what's in your pictures:
QTabWidget* main_tabs = new QTabWidget(); main_tabs->addTab(new QWidget(), "Unsaved Document 1"); main_tabs->addTab(new QWidget(), "Unsaved Document 2"); QDockWidget* documents_panel = new QDockWidget("Documents"); QDockWidget* file_browser_panel = new QDockWidget("File Browser"); QLabel* status_text = new QLabel("Ln 1, Col 1 INS"); QTabBar* status_tabs = new QTabBar(); status_tabs->addTab(" "); status_tabs->addTab("Plain Text"); status_tabs->addTab("Tab width: 4"); QStatusBar* sb = new QStatusBar(); sb->addPermanentWidget(status_text); sb->addWidget(status_tabs); QMainWindow mw; mw.setCentralWidget(main_tabs); mw.addDockWidget(Qt::LeftDockWidgetArea, documents_panel); mw.tabifyDockWidget(documents_panel, file_browser_panel); mw.setStatusBar(sb);
-
It really does look close :)
-
How to show in the tab "Documents" opened tabs with text edits and in another tab "File Browser" the current file system?
And as you can see there are arrows "Left", "Right", "Up", a falling down menu "Bookmarks", and a some item with the name "Match Filename" in the tab "File Browser". How to add mentioned above components in the concrete tab?
-
QDockWidget has a setWidget() method to set its contents. For the documents dock you can use QListWidget to list all the documents and for the File Browser see QTreeView and QFileSystemModel.