Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to add a widget to QMainwindow in qt creator
Forum Updated to NodeBB v4.3 + New Features

How to add a widget to QMainwindow in qt creator

Scheduled Pinned Locked Moved Unsolved General and Desktop
43 Posts 5 Posters 12.2k Views 2 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.
  • V Offline
    V Offline
    veera
    wrote on 9 Oct 2017, 11:19 last edited by
    #21

    Hi ,
    No ....need to call in the run time There is Qmainwindow ui in that i have implemented there is a open pushbutton using style sheet ,if i press its has to open qtabwidget after words .....i will show my tableview in that ,its already connected with database server ..........this is my implementation idea....

    M 1 Reply Last reply 9 Oct 2017, 11:22
    0
    • V veera
      9 Oct 2017, 11:19

      Hi ,
      No ....need to call in the run time There is Qmainwindow ui in that i have implemented there is a open pushbutton using style sheet ,if i press its has to open qtabwidget after words .....i will show my tableview in that ,its already connected with database server ..........this is my implementation idea....

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 9 Oct 2017, 11:22 last edited by
      #22

      @veera

      ok if you new a tabwidget with no parent, it should become window
      then you just a page to it and it should be it

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veera
        wrote on 9 Oct 2017, 11:25 last edited by
        #23

        how to add and open the page after click the button?

        1 Reply Last reply
        0
        • V Offline
          V Offline
          veera
          wrote on 9 Oct 2017, 11:26 last edited by
          #24

          if you don't mind please elaborate the concepts.....

          M 1 Reply Last reply 9 Oct 2017, 11:29
          0
          • V veera
            9 Oct 2017, 11:26

            if you don't mind please elaborate the concepts.....

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 9 Oct 2017, 11:29 last edited by mrjj 10 Sept 2017, 11:38
            #25

            @veera

            I think i dont understand what you are asking.

            void MainWindow::on_pushButton_2_released()
            {
              QTabWidget* tw = new QTabWidget(nullptr);
              tw->addTab(new QPushButton("test"),"MYTAB");
              tw->show();
            }
            

            Will show a tabwidget as window with one Qpushbutton as tab

            alt text

            Note. just sample. it will make new each time pushed and not delete it.
            A dialog would work better.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              veera
              wrote on 9 Oct 2017, 11:44 last edited by
              #26

              sorry the main thing is that it has to open as a tab attached to main window ......

              1 Reply Last reply
              0
              • V Offline
                V Offline
                veera
                wrote on 9 Oct 2017, 11:48 last edited by
                #27

                /QTabWidget *tabWidget = new QTabWidget;

                /*QWidget *tab1 = new QWidget;
                QWidget *tab2 = new QWidget;
                QWidget *tab3 = new QWidget;
                setCentralWidget(tabWidget);
                tabWidget->insertTab(0,tab1,"Table_1 Data");
                tabWidget->insertTab(1,tab2,"Table2 data");
                tabWidget->insertTab(2,tab2,"Table3 data");
                

                // tabWidget->tabRemoved(0);
                // ui->tabWidget->removeTab(0);
                tabWidget->removeTab(2);
                Here i manually creating the widgets there are attaching with QMainwindow ....I dont want to create manually need to dynamically open it need to attached to Qmainwindow.......

                M 1 Reply Last reply 9 Oct 2017, 12:04
                0
                • V veera
                  9 Oct 2017, 11:48

                  /QTabWidget *tabWidget = new QTabWidget;

                  /*QWidget *tab1 = new QWidget;
                  QWidget *tab2 = new QWidget;
                  QWidget *tab3 = new QWidget;
                  setCentralWidget(tabWidget);
                  tabWidget->insertTab(0,tab1,"Table_1 Data");
                  tabWidget->insertTab(1,tab2,"Table2 data");
                  tabWidget->insertTab(2,tab2,"Table3 data");
                  

                  // tabWidget->tabRemoved(0);
                  // ui->tabWidget->removeTab(0);
                  tabWidget->removeTab(2);
                  Here i manually creating the widgets there are attaching with QMainwindow ....I dont want to create manually need to dynamically open it need to attached to Qmainwindow.......

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 9 Oct 2017, 12:04 last edited by
                  #28

                  @veera said in How to add a widget to QMainwindow in qt creator:

                  I dont want to create manually need to dynamically open it

                  But using addTab or insertTab IS dynamically ???????
                  as versus just adding them in Designer.

                  1 Reply Last reply
                  1
                  • V Offline
                    V Offline
                    veera
                    wrote on 9 Oct 2017, 12:47 last edited by
                    #29

                    okay fine how about the display of the tabs need join to main window how we can achieve it ?

                    M 1 Reply Last reply 9 Oct 2017, 13:07
                    0
                    • V veera
                      9 Oct 2017, 12:47

                      okay fine how about the display of the tabs need join to main window how we can achieve it ?

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 9 Oct 2017, 13:07 last edited by
                      #30

                      @veera

                      • display of the tabs need join to main window

                      the tabs are widgets. you can add any the widgets to main window if you use a layout or another tabwidget.

                      if you need them as tab still, then another tabwidget is needed.

                      else im not sure what you mean by "join"

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        veera
                        wrote on 9 Oct 2017, 13:26 last edited by
                        #31

                        okay thanks for the support i will try now ...

                        M 1 Reply Last reply 9 Oct 2017, 13:58
                        0
                        • V veera
                          9 Oct 2017, 13:26

                          okay thanks for the support i will try now ...

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 9 Oct 2017, 13:58 last edited by
                          #32

                          @veera

                          Hopefully it answered what you asked.
                          I not sure what your real issue was, what you have tried and what didnt work :)

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            veera
                            wrote on 10 Oct 2017, 07:22 last edited by
                            #33

                            Hi In the screen below image I have mentioned like this type in one mainwindow button need to implement i could not understand how to start ........please help me0_1507620122291_myui.png

                            J 1 Reply Last reply 10 Oct 2017, 07:26
                            0
                            • V veera
                              10 Oct 2017, 07:22

                              Hi In the screen below image I have mentioned like this type in one mainwindow button need to implement i could not understand how to start ........please help me0_1507620122291_myui.png

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 10 Oct 2017, 07:26 last edited by
                              #34

                              @veera Sorry, it is really hard to understand you. Isn't this just a QTabWidget containing another QTabWidgets in its tabs?

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • V Offline
                                V Offline
                                veera
                                wrote on 10 Oct 2017, 07:48 last edited by
                                #35

                                No it should have some control if you click it it has to open it as a tab need to open as you can see in the image i have uploaded?

                                J 1 Reply Last reply 10 Oct 2017, 09:10
                                0
                                • V veera
                                  10 Oct 2017, 07:48

                                  No it should have some control if you click it it has to open it as a tab need to open as you can see in the image i have uploaded?

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 10 Oct 2017, 09:10 last edited by
                                  #36

                                  @veera You can either use real buttons or qtabwidget containing other qtabwidget and react on tab switch using
                                  http://doc.qt.io/qt-5/qtabwidget.html#currentChanged
                                  But I don't really understand what you're asking for...

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • V Offline
                                    V Offline
                                    veera
                                    wrote on 10 Oct 2017, 09:46 last edited by
                                    #37

                                    I have shown in the image .....i dont need full implementation i just need a sample of the image with only one control needed thats it.

                                    1 Reply Last reply
                                    0
                                    • V Offline
                                      V Offline
                                      veera
                                      wrote on 10 Oct 2017, 09:49 last edited by
                                      #38

                                      single menus control with whenever if you click means it has to open a page or tab with (close X) on it ......thats it.

                                      J 1 Reply Last reply 10 Oct 2017, 10:26
                                      0
                                      • V veera
                                        10 Oct 2017, 09:49

                                        single menus control with whenever if you click means it has to open a page or tab with (close X) on it ......thats it.

                                        J Offline
                                        J Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 10 Oct 2017, 10:26 last edited by
                                        #39

                                        @veera What is exactly the problem? You can just connect a slot to clicked() signal of a push button (if you use a push button) and show what ever you need in that slot.

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        0
                                        • V Offline
                                          V Offline
                                          veera
                                          wrote on 10 Oct 2017, 12:24 last edited by
                                          #40

                                          please find my screen shots these dialog boxes are opening separately ...i don't want to open it separately need to join them to main window as well as it will not allow to do anything after closing window only we can open another window.....0_1507638234622_mygui12.png 0_1507638243458_mygui45.png 0_1507638250188_mygui7.png

                                          J 1 Reply Last reply 10 Oct 2017, 12:55
                                          0

                                          30/43

                                          9 Oct 2017, 13:07

                                          • Login

                                          • Login or register to search.
                                          30 out of 43
                                          • First post
                                            30/43
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved