Regarding displaying image in grid.
I am trying to display the images in the grid using the below code.
I am able to get the first image.But second image won't come .
Code:
//grid->setColumnMinimumWidth(2,30);
imageLabel->setScaledContents(true);
setCentralWidget(imageLabel);
resize(100,100);
QString NextImagepath
= "c:\\Data\\Images\\Pictures\\error.bmp";
imageLabel->setPixmap(Nextimage);
grid->addWidget(imageLabel,0,0);
grid->addWidget(imageLabel,0,1);
what is the reason behind this?Information on this would be helpful.
Re: Regarding displaying image in grid.
You can't add the same widget two times to the layout. If you do that the widget will be removed from the first layout and put into the second one.
Re: Regarding displaying image in grid.
I tried using different widget.Again the same problem.
What can be the problem...
QGridLayout *grid = new QGridLayout();
//grid->setColumnMinimumWidth(2,30);
imageLabel = new QLabel;
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
imageLabel->setScaledContents(true);
setCentralWidget(imageLabel);
resize(50,50);
QString NextImagepath = "c:\\Data\\Images\\Pictures\\error.bmp";
QPixmap Nextimage(NextImagepath);
imageLabel->setPixmap(Nextimage);
grid->addWidget(imageLabel,0,0);
ilabel2 = new QLabel;
ilabel2->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
ilabel2->setScaledContents(true);
setCentralWidget(imageLabel);
resize(50, 50);
QString NextImagepath1 = "c:\\Data\\Images\\Pictures\\b_prevtrack_on.pn g";
QPixmap Nextimage1(NextImagepath1);
ilabel2->setPixmap(Nextimage1);
grid->addWidget(ilabel2,2,1);
Re: Regarding displaying image in grid.
This time you are replacing one central widget with another so again you only see one widget and the other gets deleted (or hidden). Please stop guessing and look into the documentation of QGridLayout, there is an example there that shows how to add widgets to the layout.