c++ - How to make a 2d Array in QT? -
hi question simple, asked in qt forums nobody answer me.
i wanted make 2d array of qlabel, can me, read it, use dynamic vector, this:
<qvector <data_type>> i can't use (my project don't have use yet, crap specifications know), have use 2d in c++ or c. edit: have 2d array dont know how show it, have this, , don't give me errors:
qwidget *mainwidget = new qwidget; qlabel **maze; maze= new qlabel*[x]; (int = 0; < x; i++) { maze[i]= new qlabel[y]; } for(int i=0;i<x;i++){ for(int j=0;j<y;j++){ maze[i][j].setpixmap(test); maze[i][j].move(i*60,j*60); } } mainwidget->show(); setcentralwidget(mainwidget); now want show images, once run project, no images appear, widget thing right? how show in main window? need 2d widget too? time.
assuming x , y number of rows , columns, correspondingly, can trick:
[..] qgridlayout *grid = new qgridlayout; (int = 0; < x; i++) { (int j = 0; j < y; j++) { qlabel *label = new qlabel(this); label->setpixmap("path_of_the_image"); grid.addwidget(label, i, j); } } [..]
Comments
Post a Comment