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. What is the red flag on centralWidget

What is the red flag on centralWidget

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 7.9k Views 1 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.
  • A Offline
    A Offline
    Arqam
    wrote on last edited by Arqam
    #1

    When we open a new QWidget project we see a red flag :

    0_1503487527726_Screen Shot 2017-08-23 at 4.54.09 PM.png

    What is this and is there anything wrong that we need to change and implement, as in one of my project it did disappear, and in other project where its still there if I do :

        ui->centralWidget->layout()->setMargin(0);
        ui->centralWidget->layout()->setSpacing(0);
    

    The code breaks and the program ends.

    I know it means breaking the layout, but how in Central Widget?

    jsulmJ kshegunovK 2 Replies Last reply
    0
    • A Arqam

      When we open a new QWidget project we see a red flag :

      0_1503487527726_Screen Shot 2017-08-23 at 4.54.09 PM.png

      What is this and is there anything wrong that we need to change and implement, as in one of my project it did disappear, and in other project where its still there if I do :

          ui->centralWidget->layout()->setMargin(0);
          ui->centralWidget->layout()->setSpacing(0);
      

      The code breaks and the program ends.

      I know it means breaking the layout, but how in Central Widget?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Arqam said in What is the red flag on centralWidget:

      ui->centralWidget->layout()->setMargin(0);

      If this line is crashing your app it means that either there is no central widget or the central widget does not have a layout. Very easy to find out using debugger or qDebug...

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

      1 Reply Last reply
      1
      • A Arqam

        When we open a new QWidget project we see a red flag :

        0_1503487527726_Screen Shot 2017-08-23 at 4.54.09 PM.png

        What is this and is there anything wrong that we need to change and implement, as in one of my project it did disappear, and in other project where its still there if I do :

            ui->centralWidget->layout()->setMargin(0);
            ui->centralWidget->layout()->setSpacing(0);
        

        The code breaks and the program ends.

        I know it means breaking the layout, but how in Central Widget?

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        @Arqam said in What is the red flag on centralWidget:

        What is this and is there anything wrong that we need to change and implement

        This means you have no layout attached to that widget (you have a layout inside of it though). What you should do is break the inner layout, right click on the top-level widget and from the context menu select: "Lay out > Vertically". This will attach a vertical layout the widget (you won't see it with a red border) and put the child widgets inside it.

        Read and abide by the Qt Code of Conduct

        A 1 Reply Last reply
        1
        • kshegunovK kshegunov

          @Arqam said in What is the red flag on centralWidget:

          What is this and is there anything wrong that we need to change and implement

          This means you have no layout attached to that widget (you have a layout inside of it though). What you should do is break the inner layout, right click on the top-level widget and from the context menu select: "Lay out > Vertically". This will attach a vertical layout the widget (you won't see it with a red border) and put the child widgets inside it.

          A Offline
          A Offline
          Arqam
          wrote on last edited by
          #4

          @kshegunov So say out widget is like this, so right clicking on the central widget doesn't give anything at that time.

          0_1503488518216_Screen Shot 2017-08-23 at 5.11.40 PM.png

          J.HilkJ kshegunovK 2 Replies Last reply
          0
          • A Arqam

            @kshegunov So say out widget is like this, so right clicking on the central widget doesn't give anything at that time.

            0_1503488518216_Screen Shot 2017-08-23 at 5.11.40 PM.png

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @Arqam you need to right click on the toplvl item in your case QMainWindow - > Bottom most option in the popup menu is adding a layout.


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            A 1 Reply Last reply
            1
            • J.HilkJ J.Hilk

              @Arqam you need to right click on the toplvl item in your case QMainWindow - > Bottom most option in the popup menu is adding a layout.

              A Offline
              A Offline
              Arqam
              wrote on last edited by
              #6

              @J.Hilk For that also we need at least one child element right

              J.HilkJ 1 Reply Last reply
              0
              • A Arqam

                @J.Hilk For that also we need at least one child element right

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @Arqam IIRC, when you create a QMainWindow via QtDesigner, you'll always have 2 childen, the QWidget with the Objectname "centralWidget" and a QMenuBar.


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                0
                • A Arqam

                  @kshegunov So say out widget is like this, so right clicking on the central widget doesn't give anything at that time.

                  0_1503488518216_Screen Shot 2017-08-23 at 5.11.40 PM.png

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #8

                  Just click on the empty space and select the appropriate layout (see screenshot).0_1503489076550_Screenshot_20170823_145036.png

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  3

                  • Login

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