Important: Please read the Qt Code of Conduct -

Using directory of an .exe dialog box to display image in graphicview of other window

  • Hello,

    I have created a mainWindow consisted of a button_1 and one graphicsview. When I press the button, I run another window.exe (it is a dialog box in order to find the directory of a png file.) On the dialog box there is a another button_2, and when I press it I want to take the directory and open the png file in the graphics view of my mainWindow. I know how to display an image in a graphics view, but I do not know how to take the directory from the dialog box (window.exe) and open the png image in the graphics view of my mainwindow.
    I hope someone could help me

  • Why do you use two different binaries for it? Maybe it will be better to run them in one application?

  • I am beginner in using Qt. I created the window.exe first and then the MainWindow application and I included the window.exe with the press of one button.I thought it would be easier. I do not really know how to pass my directory from the directory dialog box, to my MainWindow in order to display the image in a graphicsview. Is it possible?
    Now I am reading something about hyperlinks in Qt. Would it be a solution? What would you suggest?

    Thanks for your reply

  • I think that I understood what do you mean. I created a function like this:
    Did you refer to this?

    @void my_mainwindow::push_button_File(void)

     QString fileName = QFileDialog::getOpenFileName(this,
                                     tr("Open File"), QDir::currentPath());
     if (!fileName.isEmpty()) {
        QGraphicsScene * scene = new QGraphicsScene();
    scene->addPixmap(QPixmap(fileName, 0, Qt::AutoColor));

    return ;

Log in to reply