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. Adding Qt Widget class - starting with "layout"

Adding Qt Widget class - starting with "layout"

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 5 Posters 1.3k 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 15 Oct 2019, 13:43 last edited by aha_1980
    #1

    I am following the GUI documentation and somehow missed ability to start the "form" with layout "form" and ended up with enclosed setting of new form having no layout layer.

    I am enclosing both MainWindow (test modified by me ) and the new class forms for comparison.

    Two questions
    what did I do wrong to miss the "layout" part of the tree?
    do I have to delete all from the new form and just start with desired "layout". as "form layout" AKA can I insert the "top (tree) layout" ?

    Also
    what is "central widget" and how it got into the tree?

    e071b33f-0547-4ab5-836b-aa5cf0efb91e-image.png

    P 1 Reply Last reply 15 Oct 2019, 14:02
    0
    • A Anonymous_Banned275
      15 Oct 2019, 13:43

      I am following the GUI documentation and somehow missed ability to start the "form" with layout "form" and ended up with enclosed setting of new form having no layout layer.

      I am enclosing both MainWindow (test modified by me ) and the new class forms for comparison.

      Two questions
      what did I do wrong to miss the "layout" part of the tree?
      do I have to delete all from the new form and just start with desired "layout". as "form layout" AKA can I insert the "top (tree) layout" ?

      Also
      what is "central widget" and how it got into the tree?

      e071b33f-0547-4ab5-836b-aa5cf0efb91e-image.png

      P Offline
      P Offline
      Pl45m4
      wrote on 15 Oct 2019, 14:02 last edited by Pl45m4
      #2

      @AnneRanch

      First image:
      You have added an additional layout (vertical) on your centralWidget , which has no layout. Better set a vertical layout to your centralWidget instead of adding a new one.

      @AnneRanch said in Adding Qt Widget class - starting wiht "layout":

      what is "central widget" and how it got into the tree

      https://doc.qt.io/qt-5/qmainwindow.html#details

      @AnneRanch said in Adding Qt Widget class - starting wiht "layout":

      do I have to delete all from the new form and just start with desired "layout". as "form layout" AKA can I insert the "top (tree) layout" ?

      You can keep the centralWidget as it's the main container / main widget inside a QMainWindow


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      A 1 Reply Last reply 15 Oct 2019, 15:04
      2
      • C Offline
        C Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on 15 Oct 2019, 14:18 last edited by
        #3

        To add to what @Pl45m4 already said:

        what did I do wrong to miss the "layout" part of the tree?

        You probably dragged a layout from the widgets palette on the left side. This results in the hierarchy you see - creates an anonymous widget child and sets a layout on it. To set a layout directly on the centralWidget select it and press any of the layout icons on the top toolbar or right click and choose one of the options in "Lay out" menu.

        do I have to delete all from the new form and just start with desired "layout". as "form layout" AKA can I insert the "top (tree) layout" ?

        You can drag widgets around between layouts or you can right click on a layout and change it to something else via that same "Lay out" menu. To get rid of that extra level in your picture select tabWidget and drag it to the centralWidget, then delete verticalLayout, select centralWidget and then press one of the layout buttons on top toolbar.

        1 Reply Last reply
        1
        • P Pl45m4
          15 Oct 2019, 14:02

          @AnneRanch

          First image:
          You have added an additional layout (vertical) on your centralWidget , which has no layout. Better set a vertical layout to your centralWidget instead of adding a new one.

          @AnneRanch said in Adding Qt Widget class - starting wiht "layout":

          what is "central widget" and how it got into the tree

          https://doc.qt.io/qt-5/qmainwindow.html#details

          @AnneRanch said in Adding Qt Widget class - starting wiht "layout":

          do I have to delete all from the new form and just start with desired "layout". as "form layout" AKA can I insert the "top (tree) layout" ?

          You can keep the centralWidget as it's the main container / main widget inside a QMainWindow

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on 15 Oct 2019, 15:04 last edited by Anonymous_Banned275
          #4

          @Pl45m4 Thanks for the link. As always - the hardest part of getting info is to have an idea WHERE to find it or what to search for,
          That IMHO it is a primary goal of forum and this one is exceptionally helpful in "directing traffic ".

          You have actually answered another question I have been struggling with since I started using Qt.
          Is there a "main window"?

          I am comparing my code to other program and that one has multiple windows.
          I am going to rebuild my test program from scratch and hopefully won't have many questions after I get the "main window" concept going,

          I hope it is OK to add to this , I do not want to be accused of reposting stuff.

          I am working on "main window" and trying to use Qt Designer , not code, to design one of the already present "status" bars.
          I cannot find how - there seems to be no GUI option to edit the bar.
          Any hit woudl be appreciated.

          Thanks

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mranger90
            wrote on 15 Oct 2019, 15:32 last edited by
            #5

            @AnneRanch
            It seems that you have many questions that are about fundamental Qt issues. That's ok. We all started somewhere. Can I suggest that instead of trying to figure this all out by yourself, there are a lot of tutorials on YouTube and other sources that can help you get over the initial learning hump. The ones from VoidRealms are a little aged, but are particularly good at illustrating a single concept. I'm sure there are others that may help.

            A 1 Reply Last reply 15 Oct 2019, 17:02
            2
            • M mranger90
              15 Oct 2019, 15:32

              @AnneRanch
              It seems that you have many questions that are about fundamental Qt issues. That's ok. We all started somewhere. Can I suggest that instead of trying to figure this all out by yourself, there are a lot of tutorials on YouTube and other sources that can help you get over the initial learning hump. The ones from VoidRealms are a little aged, but are particularly good at illustrating a single concept. I'm sure there are others that may help.

              A Offline
              A Offline
              Anonymous_Banned275
              wrote on 15 Oct 2019, 17:02 last edited by
              #6

              @mranger90 I am sure no matter how reply it will not personal satisfy you.
              But out of courtesy - I wish not to engage in discussion about my ways of learning Qt. Fair?

              P 1 Reply Last reply 15 Oct 2019, 21:36
              0
              • A Anonymous_Banned275
                15 Oct 2019, 17:02

                @mranger90 I am sure no matter how reply it will not personal satisfy you.
                But out of courtesy - I wish not to engage in discussion about my ways of learning Qt. Fair?

                P Offline
                P Offline
                Pl45m4
                wrote on 15 Oct 2019, 21:36 last edited by Pl45m4
                #7

                @AnneRanch

                According to your "status bar" question.

                The status bar, as well as menu bar and centralWidget, is always there, if you create a new QMainWindow. If you didn't delete it, it should be accessible by statusBar() from inside your mainWindow class.

                You can set your own QWidget as statusBar or work with the default one (displaying status messages, logs, info.. etc).

                https://doc.qt.io/qt-5/qstatusbar.html

                Everything depends on what you want to do :)
                Reading the Qt Doc here and there may help, try things out, check out functions, signals and from your Qt Creators auto-complete function and play around a bit.
                If you have no experience with Qt / Qt Creator it might look a bit confusing and hard to understand, but actually (IMO) the QT stuff is pretty intuitive and easy to learn.
                (At least the 'basic' things like creating widgets, defining layouts, signals & slots mechanism and so on)

                One last advice :)
                The Qt Designer, where you've created your QTabWidget is nice to quickly create a simple GUI. But it will help a lot if you try to re-create the same GUI with code only.
                Everything that can be done with Qt Designer, can be done with code, but there are several things where you have to use code, because Qt Designer is limited to some straightforward drag'n'drop widgets and static behavior.


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                A 1 Reply Last reply 15 Oct 2019, 22:08
                0
                • P Pl45m4
                  15 Oct 2019, 21:36

                  @AnneRanch

                  According to your "status bar" question.

                  The status bar, as well as menu bar and centralWidget, is always there, if you create a new QMainWindow. If you didn't delete it, it should be accessible by statusBar() from inside your mainWindow class.

                  You can set your own QWidget as statusBar or work with the default one (displaying status messages, logs, info.. etc).

                  https://doc.qt.io/qt-5/qstatusbar.html

                  Everything depends on what you want to do :)
                  Reading the Qt Doc here and there may help, try things out, check out functions, signals and from your Qt Creators auto-complete function and play around a bit.
                  If you have no experience with Qt / Qt Creator it might look a bit confusing and hard to understand, but actually (IMO) the QT stuff is pretty intuitive and easy to learn.
                  (At least the 'basic' things like creating widgets, defining layouts, signals & slots mechanism and so on)

                  One last advice :)
                  The Qt Designer, where you've created your QTabWidget is nice to quickly create a simple GUI. But it will help a lot if you try to re-create the same GUI with code only.
                  Everything that can be done with Qt Designer, can be done with code, but there are several things where you have to use code, because Qt Designer is limited to some straightforward drag'n'drop widgets and static behavior.

                  A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on 15 Oct 2019, 22:08 last edited by
                  #8

                  @Pl45m4
                  Figured it out.
                  Main Window is different than plain QWidget- with many default parts.
                  Automation strikes again. All I have to do is RTFM!

                  Still looking for a way to see how a QWidget class gets "associated " with form.

                  JKSHJ 1 Reply Last reply 15 Oct 2019, 22:16
                  0
                  • A Anonymous_Banned275
                    15 Oct 2019, 22:08

                    @Pl45m4
                    Figured it out.
                    Main Window is different than plain QWidget- with many default parts.
                    Automation strikes again. All I have to do is RTFM!

                    Still looking for a way to see how a QWidget class gets "associated " with form.

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on 15 Oct 2019, 22:16 last edited by
                    #9

                    @AnneRanch said in Adding Qt Widget class - starting with "layout":

                    Still looking for a way to see how a QWidget class gets "associated " with form.

                    This might provide some insight: https://doc.qt.io/qt-5/uic.html

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    1

                    1/9

                    15 Oct 2019, 13:43

                    • Login

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