I have written some program in Qt on Windows PC and now trying to recompile it on a Raspberry Pi. The problem I'm facing with, is the following: There are some images to be loaded. These images shall be saved in a QMap<int, QPixmap>. During loading of an Image, I'm creating an instance of QPixmap object, but it fails with "Segmentation fault"
//****************************************//
QMap<int, QPixmap> deviceImages;
//****************************************//
void MainWindow::loadImages(MainWindow *ui)
{
int index = 0;
QString ImagesPath = QDir(".").absolutePath() + "/Images/";
QDir Image_Dir(ImagesPath);
qDebug() << Image_Dir.entryInfoList(QDir::Files);
for(const QFileInfo &fileInfo : Image_Dir.entryInfoList(QDir::Files))
{
if(fileInfo.suffix() == "png")
{
QString fileName = fileInfo.absoluteFilePath();
QPixmap *image = new QPixmap(); // Segmentation Fault here
if(image->load(fileName))
{
deviceImages.insert(index++, *image);
}
}
}
ui->success = QPixmap(ImagesPath + "/SlotAnimation/success.png");
ui->warning= QPixmap(ImagesPath + "/SlotAnimation/warning.png");
ui->safety= QPixmap(ImagesPath + "/SlotAnimation/safety.png");
ui->notConnected = QPixmap(ImagesPath + "/SlotAnimation/notConnected.png");
}
I have tried some other variants to load a QPixmap, but it always causes a Segmentation Fault:
- QPixmap *image = new QPixmap(); image->load(fileName)
- QPixmap image = Pixmap(fileName);
- QPixmap image = Pixmap(); image.load(fileName);
I have also tried to start the program as a SUDO, it has the same Problem.
Could someone explain where is the problem?