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 create a simple box like layout
Forum Updated to NodeBB v4.3 + New Features

How to create a simple box like layout

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 3.4k 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.
  • R Offline
    R Offline
    raaghuu
    wrote on last edited by
    #2

    maybe you should try adding widgets to the main widget without specifying any layout...that should do what you want,i think(not sure but worth a try)...
    EDIT-ok that was stupid of me... i think its the QGridLayout you're looking for...it should do what that pic shows...what didn't work for you in it?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      developer
      wrote on last edited by
      #3

      the problem with grid layout it is fixed for eg. if i specify a grid layout of 2 rowsw each contains 5 widgets so they will take whole parent widget and spacing between them increases and decreases as i change the widow/widget size and they does not allow me to append and actually quite stupid.
      the first one i have tried did,nt worked

      1 Reply Last reply
      0
      • R Offline
        R Offline
        raaghuu
        wrote on last edited by
        #4

        @
        #include "mainw.h"

        MainW::MainW(QWidget *parent) :
        QWidget(parent)
        {
        noi=0;
        row=1;
        col=1;
        layout=new QGridLayout;
        QPushButton *button=new QPushButton(tr(""));
        button->setFixedSize(10,10);
        connect(button,SIGNAL(clicked()),this,SLOT(addW()));
        layout->addWidget(button,0,0);
        setLayout(layout);
        }

        void MainW::addW()
        {
        layout->addWidget(new QLabel(tr("%1").arg(++noi)),row,col-1);
        if(col==5)
        {
        row++;
        col=1;
        }
        else
        col++;
        }
        @

        try this...
        EDIT-ok i don't know how to make this look better...all the indentation was eaten(tell me if you know how to add code)
        noi(int), row(int), col(int), layout(QGridLayout) are private members...addW() private slot....SIGNAL->clicked()...SLOT->addW()...sorry for the mess

        [EDIT: code formatting added. Wrap in @-tags or use the button in the editor, Volker]

        1 Reply Last reply
        0
        • D Offline
          D Offline
          developer
          wrote on last edited by
          #5

          hey man i have tried this but it is not good and works awefull my application iwll be hated i dont want that perhaps a better solution which saves memory.
          I am trying but they to sucks but i will keep trying

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raaghuu
            wrote on last edited by
            #6

            ty Volker sir... i was actually using my browser with images off(for faster loading...my isp is really bad... cuts the speed to 156 kbps after 5gb every month) so didn't see the buttons...
            Developer... c'mon man...its not that bad, i think...a little time spent on tweaking it will let you achieve what you want... but then its your choice... that's all i can think of for what you are asking...

            1 Reply Last reply
            0
            • D Offline
              D Offline
              developer
              wrote on last edited by
              #7

              ok man i tiwll do that and i am doing first i will draw the raw skecthes and then mix layouts to achive my target what about using qml for this

              1 Reply Last reply
              0
              • W Offline
                W Offline
                Wilk
                wrote on last edited by
                #8

                Hello.
                Please, use punctuation marks in you posts - it's hard to understand, what do you want while reading a stream of words.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  developer
                  wrote on last edited by
                  #9

                  OK @ Wilk i will use Punctuation in my Posts.

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    raaghuu
                    wrote on last edited by
                    #10

                    [quote author="developer" date="1340528028"]what about using qml for this[/quote]
                    i don't have any experience in qml... so can't say nething about that

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      Wilk
                      wrote on last edited by
                      #11

                      [quote author="developer" date="1340529246"]OK @ Wilk i will use Punctuation in my Posts.[/quote]

                      Thank you for understanding.

                      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