MyClass::LoadImages(){
int COLUMN;
filters << "snapshot-*" ;
directory.setNameFilters(filters);
files
= directory.
entryList(filters,
QDir::Files |
QDir::NoSymLinks);
c=0; COLUMN = 2;
QLabel *pixmapLabels
[100] [2];
NumStates_New = 0;
NumStates_New = files.size()/2;
if ( files.size()%2 >0 ) {
NumStates_New++;
}
for (int i = 0; i < NumStates_New; ++i) {
for (int j = 0; j < COLUMN; ++j) {
pixmapLabels[i][j] = createPixmapLabel();
pixmapLabels[i][j]->resize(5,5);
// pixmapLabels[i][j]->show();
SnapLayout->addWidget(pixmapLabels[i][j], i + 1, j + 1 );
// SnapLayout->update();
}
}
r=0, c=0;
for (int i = 0; i < files.size(); ++i) {
fileName = directory.absolutePath();
fileName.append("/");
fileName.append(files.at(i).toLocal8Bit().constData());
image->load(fileName);
if (!image->isNull()){
}
else{
}
this->icon = icon;
this
->size
= QSize(110,
102);
pixmapLabels[r][c]->setPixmap(pixmap);
pixmapLabels[r][c]->setToolTip(fileName);
pixmapLabels[r][c]->show();
c++; if (c>=COLUMN) { c=0; r++; }
}
}
QLabel *MyClass
::createPixmapLabel() {
label->setEnabled(true);
label->setAlignment(Qt::AlignCenter);
label->setText("Picture");
label->setAutoFillBackground(true);
label->setMinimumSize(110,102);
return label;
}
MyClass::LoadImages(){
int COLUMN;
QImage *image = new QImage();
QIcon icon;
filters << "snapshot-*" ;
directory.setNameFilters(filters);
files = directory.entryList(filters, QDir::Files | QDir::NoSymLinks);
c=0; COLUMN = 2;
QLabel *pixmapLabels [100] [2];
NumStates_New = 0;
NumStates_New = files.size()/2;
if ( files.size()%2 >0 ) {
NumStates_New++;
}
for (int i = 0; i < NumStates_New; ++i) {
for (int j = 0; j < COLUMN; ++j) {
pixmapLabels[i][j] = createPixmapLabel();
pixmapLabels[i][j]->resize(5,5);
// pixmapLabels[i][j]->show();
SnapLayout->addWidget(pixmapLabels[i][j], i + 1, j + 1 );
// SnapLayout->update();
}
}
r=0, c=0;
for (int i = 0; i < files.size(); ++i) {
fileName = directory.absolutePath();
fileName.append("/");
fileName.append(files.at(i).toLocal8Bit().constData());
image->load(fileName);
if (!image->isNull()){
icon.addPixmap(QPixmap::fromImage(*image), QIcon::Normal, QIcon::On);
}
else{
QMessageBox::critical(this, "Picture error", "Picture error", QMessageBox::Ok, QMessageBox::NoButton);
}
this->icon = icon;
this->size = QSize(110,102);
QPixmap pixmap = icon.pixmap(size, QIcon::Normal, QIcon::On);
pixmapLabels[r][c]->setPixmap(pixmap);
pixmapLabels[r][c]->setToolTip(fileName);
pixmapLabels[r][c]->show();
c++; if (c>=COLUMN) { c=0; r++; }
}
}
QLabel *MyClass::createPixmapLabel()
{
QLabel *label = new QLabel;
label->setEnabled(true);
label->setAlignment(Qt::AlignCenter);
label->setText("Picture");
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
label->setAutoFillBackground(true);
label->setMinimumSize(110,102);
return label;
}
To copy to clipboard, switch view to plain text mode
Bookmarks