Hello everyone,
I got a problem using Qt, i want to create another window when i click on a push button. And in this window i want to display images. Here is the code i use :
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
QWidget * centralWidget= new QWidget(mw_WatchPhotos);
mw_WatchPhotos->resize(800,600);
QGridLayout * layout = new QGridLayout();
centralWidget->setLayout(layout);
int size = 0;
int u = 1;
while ( size == 0 )
{
if(myClass->number_of_photos <= u*u) size = u;
else u++;
}
QLabel * images = new QLabel[myClass->number_of_photos];
int row = 0;
for(int i = 0 ; i < myClass->number_of_photos ; ++i)
{
if(i%size == 0 && i != 0) row++;
QPixmap myimage(QString(myClass->loadphotos_directory.c_str())+QString('/')+QString(myClass->files_name[i].c_str()));
images[i].setPixmap(myimage.scaled(800/size,600/size));
layout->addWidget(&images[i],row,i%size);
}
mw_WatchPhotos->setCentralWidget(centralWidget);
mw_WatchPhotos->show();
|
In the code "mw_WatchPhotos" is a QMainWindow object declared in the class members.
The problem is when i launch that. The first time I click on the button the images are displayed correctly. But if I close the window and click again then images are going to display but just after i have an error :
"Debug Assertion Failed !"
The entire message of the error is in the attachment (Screenshot of the error).
Do you know why it does that ?
Thank you for your help,
Vincent.