Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Creating the concrete main window with items.

    General and Desktop
    3
    9
    254
    Loading More Posts
    • 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.
    • V
      Vadim Chernetsov last edited by Vadim Chernetsov

      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.
      PlumaPicture1.jpg

      When I choose the menu "View" and press on the action "Side Pane"
      PlumaPicture2.jpg

      then a side pane appers.
      PlumaPicture3.jpg

      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.
      PlumaPicture4.jpg

      When I press on the action "Side Pane" at the second time then that pane disappears.

      I have the next questions:

      1. 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?
      2. 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.

      mrjj Chris Kawa 2 Replies Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion @Vadim Chernetsov last edited by

        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-menu

        2
        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.

        V 1 Reply Last reply Reply Quote 1
        • V
          Vadim Chernetsov @mrjj last edited by Vadim Chernetsov

          @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 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @Vadim Chernetsov last edited by

            @Vadim-Chernetsov

            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.

            V 1 Reply Last reply Reply Quote 0
            • V
              Vadim Chernetsov @mrjj last edited by

              @mrjj

              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?

              1 Reply Last reply Reply Quote 0
              • Chris Kawa
                Chris Kawa Moderators @Vadim Chernetsov last edited by

                @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);
                
                1 Reply Last reply Reply Quote 2
                • mrjj
                  mrjj Lifetime Qt Champion last edited by

                  It really does look close :)
                  alt text

                  1 Reply Last reply Reply Quote 2
                  • V
                    Vadim Chernetsov last edited by Vadim Chernetsov

                    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?

                    1 Reply Last reply Reply Quote 0
                    • Chris Kawa
                      Chris Kawa Moderators last edited by

                      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.

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post