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 do this layout in code (runtime)
Forum Updated to NodeBB v4.3 + New Features

How to do this layout in code (runtime)

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 456 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.
  • R_IrudezuR Offline
    R_IrudezuR Offline
    R_Irudezu
    wrote on last edited by
    #1

    0_1545289150328_Untitled.png

    Can anyone help me with how to to this layout in code?

    Keizoku wa chikaranari.

    J.HilkJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Why not use Qt designer for it? And even if you won't use designer you can use the generated code from there and adjust it afterwards.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      5
      • R_IrudezuR R_Irudezu

        0_1545289150328_Untitled.png

        Can anyone help me with how to to this layout in code?

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

        @R_Irudezu
        because it's close to christmas:

        int main(int argc, char *argv[])
        {
            QApplication a(argc, argv);
        
            QFrame *frame = new QFrame();
            frame->setStyleSheet("QLabel{background-color:white; border: 1px solid black;}");
            QGridLayout *gLayout = new QGridLayout(frame);
        
            gLayout->addWidget(new QLabel(frame),0,0,1,3);
            gLayout->addWidget(new QLabel(frame),1,0,3,1);
            gLayout->addItem(new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding),1,1,1,1);
            gLayout->addWidget(new QLabel(frame),2,1,1,1);
            gLayout->addItem(new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding),3,1,1,1);
            gLayout->addWidget(new QLabel(frame),1,2,3,1);
        
            frame->resize(400,200);
            frame->show();
        
            return a.exec();
        }
        

        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
        5
        • R_IrudezuR Offline
          R_IrudezuR Offline
          R_Irudezu
          wrote on last edited by R_Irudezu
          #4

          @Christian-Ehrlicher i was creating widgets at runtime but it is a great idea that creating widgets in designer and check the codes but i will try first @J-Hilk ' s instance. (These row, column and spans numbers confuse me so much :/ )

          Addition: @J-Hilk many thanks, it's done. I need to do more practice about layouts :)

          Keizoku wa chikaranari.

          1 Reply Last reply
          0

          • Login

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