ayanda83
28th April 2015, 11:38
Hi there guys, my program has a function that imports a picture into the program. this function works fine when i run it on my machine (i.e. the machine I used to write the program) but when I package the program with all the dll to run it on a different machine then all of a sudden QFileDialog::getOpenFileName does not return the file path in that machine. here is my code below.
void MainWindow::on_actionOpen_triggered()
{
QString file = QFileDialog::getOpenFileName(this, "Import Picture", "/home", tr("Images (*.jpg *.png *.xpm)"));
photo = new Picture(QRectF(201,225,152,200));
if(!file.isEmpty()){
photo->setParentItem(pagesList.at(pageIterator));
photo->setPicDir(file);
photo->setPainterID(1);
for(int i = 0; i < 4; i++){
QModelIndex index = photoModel->index(i, 0, QModelIndex());
item = new QStandardItem();
QPixmap pic(file);
item->setData(pic, Qt::DecorationRole);
photoModel->setData(index, pic, Qt::DecorationRole);
}
}
}
void MainWindow::on_actionOpen_triggered()
{
QString file = QFileDialog::getOpenFileName(this, "Import Picture", "/home", tr("Images (*.jpg *.png *.xpm)"));
photo = new Picture(QRectF(201,225,152,200));
if(!file.isEmpty()){
photo->setParentItem(pagesList.at(pageIterator));
photo->setPicDir(file);
photo->setPainterID(1);
for(int i = 0; i < 4; i++){
QModelIndex index = photoModel->index(i, 0, QModelIndex());
item = new QStandardItem();
QPixmap pic(file);
item->setData(pic, Qt::DecorationRole);
photoModel->setData(index, pic, Qt::DecorationRole);
}
}
}