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. [Solved]QWidget default layout.
Forum Updated to NodeBB v4.3 + New Features

[Solved]QWidget default layout.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 6.5k 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.
  • S Offline
    S Offline
    Sam
    wrote on 22 Sept 2012, 10:20 last edited by
    #1

    Hi,

    I am working on creating a custom layout using layout manager. I have gone through the implementation of "Border Layout":http://doc.qt.digia.com/4.7-snapshot/layouts-borderlayout.html , "Card Layout":http://doc.qt.digia.com/4.7-snapshot/layout.html and "Flow Layout":http://doc.qt.digia.com/4.7-snapshot/layouts-flowlayout.html . I want to know what is the default layout for a QWidget and where can i find the implementation code. As my custom layout should have similar features to the default layout.

    Thanks.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      twsimpson
      wrote on 22 Sept 2012, 12:26 last edited by
      #2

      Widgets have no layout set by default, you give them one by using QWidget::setLayout(QLayout*)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on 22 Sept 2012, 12:33 last edited by
        #3

        Nops thats not what i am looking for, By default if I add a widget to a QWidget and i dont set any layout then I can move the widget to any location or i can set the position using setGeometry(x,y,..,..)

        So if i add a label to the widget like

        @QLabel *label = new QLabel(this);
        label->setGeometry(100,150,50,25);@

        It adds the label to the layout.

        QMainWindow also uses qmainwindowlayout internally.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          twsimpson
          wrote on 22 Sept 2012, 12:37 last edited by
          #4

          That is not using layouts, that's just painting fixed-sized and fixed-placement widgets.
          I'll show you what I mean:
          @
          int main(int argc, char** argv) {
          QApplication app(argc, argv);
          QWidget w;
          QWidget w2(&w);
          std::cout << w.layout() << std::endl;
          }
          @

          Output: 0

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on 23 Sept 2012, 06:14 last edited by
            #5

            [quote author="Terence" date="1348317435"]That is not using layouts, that's just painting fixed-sized and fixed-placement widgets.
            I'll show you what I mean:
            @
            int main(int argc, char** argv) {
            QApplication app(argc, argv);
            QWidget w;
            QWidget w2(&w);
            std::cout << w.layout() << std::endl;
            }
            @

            Output: 0[/quote]

            Thanks I understood that and have gone through the code as well of QWidget. With the help of other documentation and examples I am able to create my own custom layout.

            1 Reply Last reply
            0

            1/5

            22 Sept 2012, 10:20

            • Login

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