How to create a simple box like layout
-
i wanted o know how can i create a simple box like layout i have seen QVBoxLayout and QHBoxLayout QBoxLayout QGridLayout QListWidget QListView and many more my problem is simple i want a layout that i can append widgets inside it a nd it iwll end it in last something lie this http://dl.dropbox.com/u/35031827/vlc.png but not excatly doing this is very simple with QListWidget bcause it has just text label and icon but i want my own customized widgets instead of it i have heard of subclassing QAbstractItemview but its very complex please tell me a simple way every above classes have a problem with them.
-
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? -
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 -
@
#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]
-
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 -
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... -
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
-
Hello.
Please, use punctuation marks in you posts - it's hard to understand, what do you want while reading a stream of words. -
OK @ Wilk i will use Punctuation in my Posts.
-
[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 -
[quote author="developer" date="1340529246"]OK @ Wilk i will use Punctuation in my Posts.[/quote]
Thank you for understanding.