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
QtWS25 Last Chance

How to add a widget to QMainwindow in qt creator

Scheduled Pinned Locked Moved Unsolved General and Desktop
43 Posts 5 Posters 12.1k Views
  • 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 veera
    7 Oct 2017, 05:10

    I want to implement a sample ui please suggest me how we can achieve ?

    M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 7 Oct 2017, 05:39 last edited by mrjj 10 Jul 2017, 05:40
    #6

    @veera
    Hi
    Even when I read the post a few times, im not really sure what you ask about.

    Do you ask how to make tabs dynamic ?
    Or just widgets at runtime?

    Do you ask how to connect on to MS SQL server
    which is running in Ubuntu 16.10 ( i though it only runs on windows)
    or what do you ask about ?

    for database , you can start here
    http://doc.qt.io/qt-5/qtsql-index.html

    1 Reply Last reply
    0
    • V Offline
      V Offline
      veera
      wrote on 7 Oct 2017, 05:57 last edited by
      #7

      leave the data base part ....i want implement mainwindow with some ribbon panel controls on it if i am try to click it has to open the another window which has to open attached with mainwindow not separately thats it ...this much i need to achieve initially.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veera
        wrote on 7 Oct 2017, 06:01 last edited by
        #8

        MS Sql also runs in Linux now ....that part already implemented now i need to implement ui as similar as ribbon control need to open multiple windows or widgets attached with mainwindow....

        1 Reply Last reply
        0
        • V Offline
          V Offline
          veera
          wrote on 7 Oct 2017, 06:04 last edited by
          #9

          How about the Qt Cascaded style sheets ,by using we can achieve ?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 7 Oct 2017, 06:16 last edited by mrjj 10 Jul 2017, 06:18
            #10

            Ok
            So tasks are
            1: Create ribbon like widget.
            Try to use http://doc.qt.io/qt-5/qtabwidget.html#details
            When it works, you can style it ( with stylesheets) to make it look more like an ribbon.
            stylesheets from here http://developers-club.com/posts/48963/

            2:

            • click it has to open the another window which has to open attached with mainwindow
              What do you mean by attached here?
              if you open a dialog with the mainwindows as parent, its both blocks the mainwindow and is
              very attached to it.
              void mainwindow::somebuttonpress() {
              MyDialog dialog(this);
              dialog.exec();
              }
            1 Reply Last reply
            0
            • V Offline
              V Offline
              veera
              wrote on 7 Oct 2017, 06:53 last edited by
              #11

              Thanks for your valuable reply.......if add any dialog designer class without button to my qt project if there is a pushbutton in mainwindow.ui after that dialog window is opening it separately...i don't want to open it has a seperate window .....that has to attached to mainwindow as a tab.......in screen sheet you can see it.......

              1 Reply Last reply
              0
              • V Offline
                V Offline
                veera
                wrote on 7 Oct 2017, 07:29 last edited by veera 10 Jul 2017, 07:31
                #12

                How to display a widgets inside a main window as a tabs?

                M 1 Reply Last reply 7 Oct 2017, 10:11
                0
                • V veera
                  7 Oct 2017, 07:29

                  How to display a widgets inside a main window as a tabs?

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 7 Oct 2017, 10:11 last edited by mrjj 10 Jul 2017, 10:14
                  #13

                  @veera
                  Just place it on the form, right click and choose Insert Page
                  alt text

                  You can then add widgets to it.

                  alt text

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    veera
                    wrote on 7 Oct 2017, 10:33 last edited by veera 10 Jul 2017, 10:34
                    #14

                    during run time need to open the tabs like this please find my screen shot of the UI as like this ..... ,only minimum buttons like open button..... means need to open like this .....0_1507372314293_screenshot123.png

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 7 Oct 2017, 10:34 last edited by mrjj 10 Jul 2017, 10:37
                      #15

                      Ok but it has function for that.
                      http://doc.qt.io/qt-5/qtabwidget.html#addTab
                      so you can also do it run time.

                      1 Reply Last reply
                      1
                      • V Offline
                        V Offline
                        veera
                        wrote on 9 Oct 2017, 10:59 last edited by
                        #16

                        okay ....how to open the qtabs widget after pressing pushbutton from the mainwindow during the run time?

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

                          okay ....how to open the qtabs widget after pressing pushbutton from the mainwindow during the run time?

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

                          @veera

                          you mean after you called addTab to add it ?

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

                            No it has to call Qtabwidget with single tab...

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

                              is it possible to implement ??

                              1 Reply Last reply
                              0
                              • V veera
                                9 Oct 2017, 11:07

                                No it has to call Qtabwidget with single tab...

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 9 Oct 2017, 11:14 last edited by mrjj 10 Sept 2017, 11:16
                                #20

                                Hi
                                Who has to call ?
                                You can use addTab to add a tab
                                and u show() to show it

                                Do you have the tabwidget in UI file?
                                You from button you just add tab.
                                Tab can be any widget you like.

                                1 Reply Last reply
                                0
                                • 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

                                          15/43

                                          7 Oct 2017, 10:34

                                          • Login

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