PDA

View Full Version : QFileDialog::getOpenFileName return nothing where executed from another computer.



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);
}
}
}

d_stranz
29th April 2015, 19:12
QFileDialog::getOpenFileName does not return the file path in that machine.

How do you know it doesn't return the file path? Did you actually debug it on the other machine and verify that the file path is empty? Or did you assume that because you don't get the image you expected?

Sounds more like you haven't correctly deployed the image dlls you need to import the formats you are trying to open.

And don't reply to this with "How do I do that?" Do some independent research - use the Qt documentation, use Google, search this forum - instead of expecting everyone to spoon-feed you the answers every time you run across a problem. A good start would be to simply Google "Qt deployment" and then start reading.