May 22, 2011

jk_mk jk_mk
Lab Rat
79 posts

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
Thanks

3 replies

May 22, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1607 posts

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

May 22, 2011

jk_mk jk_mk
Lab Rat
79 posts

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

May 22, 2011

jk_mk jk_mk
Lab Rat
79 posts

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

  1. void my_mainwindow::push_button_File(void)
  2. {
  3.    
  4.      QString fileName = QFileDialog::getOpenFileName(this,
  5.                                      tr("Open File"), QDir::currentPath());
  6.      if (!fileName.isEmpty()) {
  7.         QGraphicsScene * scene = new QGraphicsScene();
  8.     scene->addPixmap(QPixmap(fileName, 0, Qt::AutoColor));
  9.          graphicsView_inputImage->setScene(scene);
  10.  
  11.      }
  12.  
  13.  
  14.  return ;
  15. }

 
  ‹‹ Looking for example using FTGL and Qt (OpenGL)      Bring window to front -> raise(),show(),activateWindow() don’t work on Windows ››

You must log in to post a reply. Not a member yet? Register here!