Results 1 to 1 of 1

Thread: Embedding Python QFileDialog Issue

  1. #1
    Join Date
    May 2015
    Qt products
    MacOS X Unix/X11 Windows

    Default Embedding Python QFileDialog Issue

    Currently, I am developing a C++ GUI application using the Qt framework. Typically this application is driven by user mouse/keyboard input. However, we have recently built a python interface using PyQt so users can drive the application with simple python scripts. This means that we have to embed a python interpreter within our C++ application. In order to initialize the interpreter, we have simply been calling Py_Initialize() in our main.cpp function after setting up the main window and then calling Py_Finalize(); before the program exits. This seems to work without issues on both Mac and Linux platforms, but I seem to be running into problems on windows.

    After Py_Initialize() has been called, user’s can open a file browser to pick a file of interest to read into the program. In the code, we use the QFileDialog::getOpenFileName static method to allow users to pick their file. However, on Windows, the program is crashing on this call. The program looks to be crashing on a call to PyDict_GetItem within the python library. I have created a super simple Qt GUI program which I have attached that exhibits the same crash. In order to run it, you need to have the Python 2.7 library installed on your machine in the location specified by the .pro file (or of course change the .pro file). C:/Python27/libs/python27.lib

    Here are some additional specs that may be useful for diagnosing the problem:
    Qt Framework Version: Qt 5.4.0
    Python Version: 2.7.10
    Building with Desktop Qt 5.4.0 MSVC2013 OpenGL 64bit Kit
    Thank you in advance for your time!

    Attached Files Attached Files

Similar Threads

  1. Python QtGui.QFileDialog.getOpenFileName hanging
    By ChrisOfBristol in forum Qt Programming
    Replies: 5
    Last Post: 27th February 2015, 00:46
  2. Embedding PyQt4 into an Application running Python via Boost::Python
    By GreyHound in forum Installation and Deployment
    Replies: 1
    Last Post: 6th February 2012, 07:48
  3. Replies: 0
    Last Post: 8th April 2011, 21:10
  4. Embedding python code in Qt
    By lixo1 in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2010, 19:02
  5. QFileDialog Issue
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2007, 05:30

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.