qt vertical and horzontal layouts inside gridlayout? -


actual one
desired one

hi all, new qt app development . attaching 2 screen shots , 1 desired ui , other created 1 using code .
believe code explain things , instead of typing here , confusing friends here . kindly suggest needs changed /updated? regards

    /*    header file    */      #ifndef widget_h     #define widget_h      #include <qwidget>      namespace ui {     class widget;     }      class widget : public qwidget     {         q_object      public:         explicit widget(qwidget *parent = 0);         ~widget();      private:        // ui::widget *ui;     };      #endif // widget_h      /*implementation  code */      #include "widget.h"     #include "ui_widget.h"     #include<qgridlayout>     #include<qvboxlayout>     #include<qhboxlayout>      widget::widget(qwidget *parent) :         qwidget(parent)//,         //ui(new ui::widget)     {         this->setgeometry(50,50,850,650);         qgridlayout *gridlayout= new qgridlayout(this);         setlayout(gridlayout);         qvboxlayout *vlayout =  new qvboxlayout(this);         qhboxlayout *hlayout =  new qhboxlayout(this);         //qwidget *tmp1 = new qwidget(this);         //qwidget *tmp2 = new qwidget(this);        // tmp1->setlayout(vlayout);        // tmp2->setlayout(hlayout);          gridlayout->addlayout(vlayout,0,3);         gridlayout->addlayout(hlayout,3,0);         //gridlayout->addwidget(tmp1,0,3,1,1);         //gridlayout->addwidget(tmp2,3,0,1,1);          qwidget *w =  new qwidget(this);          qwidget *w1 =  new qwidget(this);         qwidget *w2 =  new qwidget(this);         qwidget *w3 =  new qwidget(this);          qwidget *w11 =  new qwidget(this);         qwidget *w22 =  new qwidget(this);         qwidget *w33 =  new qwidget(this);           qwidget *w4 =  new qwidget(this);         qwidget *w5 =  new qwidget(this);          w->setstylesheet("background-color:rgb(0,0,0);");          w1->setstylesheet("background-color:rgb(255,0,0);");         w2->setstylesheet("background-color:rgb(255,0,255);");         w3->setstylesheet("background-color:rgb(0,255,0);");          w11->setstylesheet("background-color:rgb(255,0,0);");         w22->setstylesheet("background-color:rgb(255,0,255);");         w33->setstylesheet("background-color:rgb(0,255,0);");          w4->setstylesheet("background-color:rgb(0,0,255);");         w5->setstylesheet("background-color:rgb(255,255,0);");          vlayout->addwidget(w1);         vlayout->addwidget(w2);         vlayout->addwidget(w3);          vlayout->addwidget(w11);         vlayout->addwidget(w22);         vlayout->addwidget(w33);          hlayout->addwidget(w4);         hlayout->addwidget(w5);          gridlayout->addwidget(w,0,0,2,2);         show();     }      widget::~widget()     {         //delete ui;     } 

the code doesn't bad. in opinion, need tweak parameters addwidget/addlayout calls. think grid-layout should like, , choose parameters accordingly.

i try this:

// desired grid layout of size 2x2: // ................. // . row0  . row0  . // . col0  . col1  . // ................. // . row1  . row1  . // . col0  . col1  . // .................  // big widget @ row 0, column 0 gridlayout->addwidget (w, 0, 0);  // "horizontal group" @ row 1, column 0 gridlayout->addlayout (hlayout, 1, 0);  // "vertical group" @ rows 0+1 (i.e. rowspan 2), column 1 gridlayout->addlayout (vlayout, 0, 1, 2, 1); 

does work better (i havent tried out myself)?


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -