0

This seems to be a very peculiar problem which I have been working on for weeks together now. I have written the following code in Qt to move though the directories. This code works fine on my laptop which runs on Ubuntu 13.04. But when the same code is built on openSUSE, the directories are not changed in the file dialog.

void example::on_pushButton_7_clicked()
{
     mainFileName = 
         (mode == "2D")?
         QFileDialog::getOpenFileName(this, tr("MAIN File"),
                                      "../2DPrograms/" , tr("Files (*.*)")): 
         QFileDialog::getOpenFileName(this, tr("Open Example File"),
                                      "../3DPrograms/" , tr("Files (*.*)"));

     ui->mainFileName->setText(mainFileName);

}

Why does this happen? Is there any other way by which I can move through the directories?

Boris Dalstein
  • 7,015
  • 4
  • 30
  • 59
Denzil
  • 326
  • 3
  • 15
  • Unfortunately, I do not have an answer for your question, but I am very surprised that you used a ternary operator here. IMHO, it would be much more readable to use a if statement. Anyway, I would suggest you try without any branching at all (assumes `mode == "2D"` for the sake of the question) to make sure this is not the cause of the issue, and edit your code to remove this part irrelevant to the question :-) – Boris Dalstein Jul 09 '13 at 07:06
  • Did you check the Qt versions on both machines? Have you checked Qt's bugtracker for known issues? – arne Jul 09 '13 at 07:13
  • Did you check that the right line is executing? Try to place a debug output. Do both paths exist? Also it's more convenient to add a separate variable and initialize it like that: `QString path = mode == "2D" ? "../2DPrograms/" : "../3DPrograms/"`. – Pavel Strakhov Jul 09 '13 at 17:14
  • I tried it, but its' still not working. It works fine on few laptops which run on ubuntu but it doesn't run on openSUSE. – Denzil Jul 10 '13 at 07:04

0 Answers0