Results 1 to 3 of 3

Thread: What is the correct setup for developing GUI with PyQt and QML?

  1. #1
    Join Date
    Nov 2016
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default What is the correct setup for developing GUI with PyQt and QML?

    Hello,

    I am looking for advice on developing PyQt QML applications. More specifically, I would like to know what setup and working mode ensures the smoothest progress.

    I have been trying to write a GUI using the following:

    In Eclipse IDE with PyDev, I create a new PyDev project. My main .py file launches a QML application:

    Qt Code:
    1. app = QApplication(sys.argv)
    2. # Create a label and set its properties
    3. engine = QQmlApplicationEngine()
    4. engine.load(QUrl('QmlBackbone.qml'))
    5. win = engine.rootObjects()[0]
    6. win.show()
    7. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 
    The QML application is defined in a .qml file, which I create by right-clicking my PyDev project and clicking on 'add new file'. I name this file 'QmlBackbone.qml'. When the file is created, QtCreator automatically loads up, since I have given the file a .qml extension. There I can modify the QML structure.

    I launch the application from Eclipse, by running main.py. This works if there is no error in my .qml files. If there is any error, the application exits at win = engine.rootObjects()[0] (because, most probably, engine.load(QUrl('QmlBackbone.qml')) fails, so engine has not root objects), without logging any errors in QtCreator. I am left trying to guess what causes the error, which drastically amplifies the debug time.

    Another disadvantage is that I do not see a Project structure in QtCreator. Thus, I can only access .qml files from the 'Open Documents' box, provided I opened them before from Eclipse.

    In other words, QtCreator just works as a QML code editor - nothing else.

    Additionally, if I run main.py from command line python main.py, I get the following error, which I do not get when I launch from Eclipse:

    ImportError: No module named PyQt5.QtCore

    I feel like my approach is completely off-track and unproductive.

    How should I plan to develop a GUI using PyQt? Which tools should I use? What is the default recommended workflow? Should I create a project within QtCreator? Creating a project from QtCreator assumes I am using C++, but I am using Python.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: What is the correct setup for developing GUI with PyQt and QML?

    I think you'd have a much easier time using a Python-specific IDE, like IPython, Jupyter, or the more comprehensive Anaconda platform.

    If you are working in Windows, there is also a Python IDE plugin for Visual Studio which you can get for free (along with Visual Studio Express edition itself).

    Good PyQt / QtDesigner tutorial here. You should be able to adapt this once you get a good working IDE.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: What is the correct setup for developing GUI with PyQt and QML?

    Lines 5+6 look not so good in any case.

    Better just set the "visible" propery of the Window element inside the QML instead.

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 29th January 2015, 11:55
  2. Replies: 5
    Last Post: 27th June 2013, 15:22
  3. Continue developing Qt in RIM!
    By vladi in forum Jobs
    Replies: 1
    Last Post: 6th August 2012, 13:42
  4. developing with Qt on Mac OS
    By mentalmushroom in forum Newbie
    Replies: 3
    Last Post: 10th October 2011, 10:59
  5. Replies: 3
    Last Post: 30th July 2011, 22:42

Tags for this Thread

Bookmarks

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.