Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to integrate Matplotlib and NumPy into my Python and QML project for APK generation?
Forum Update on Monday, May 27th 2025

How to integrate Matplotlib and NumPy into my Python and QML project for APK generation?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 144 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shahab1234
    wrote on last edited by
    #1

    I'm currently working on a project that generates an APK file using Python and QML. I have successfully created a simple "Hello World" application, but now I want to enhance it by integrating the Matplotlib and NumPy libraries for data visualization.

    Project Overview:

    main.py: The main entry point where I want to add data processing and visualization using NumPy and Matplotlib.

    view.qml: The QML file for the UI layout, where I plan to display the plots generated by Matplotlib.

    What I want to do:

    1. Use NumPy to generate some sample data (e.g., a sine wave).

    2. Create plots using Matplotlib based on the generated data. 3. Display these plots in the QML interface while ensuring it works smoothly in the APK.

    This is my main.py file for "Hello World":

    import sys
    import lib.main_rc
    from PyQt5.QtGui import QGuiApplication
    from PyQt5.QtQml import QQmlApplicationEngine
    
    
    if __name__ == "__main__":
        app = QGuiApplication(sys.argv)
        engine = QQmlApplicationEngine(":/view.qml")
        if not engine.rootObjects():
            sys.exit()
        sys.exit(app.exec())
    

    This is my view.qml file for "Hello World":

    import QtQuick 2.0
    import QtQuick.Controls 2.5
    
    ApplicationWindow {
        visible: true
    
        Text {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
            text: "Hello World"
        }
    }
    

    Environment:

    Operating System: [Linux]

    • Target: Android APK

    Challenges I'm facing:

    • I'm unsure how to properly install and import Matplotlib and NumPy in my project, especially in the context of building for Android.

    • I need guidance on how to pass data between main.py and view.qml so that the plots generated in Python can be displayed in the QML interface.

    Are there specific examples or best practices for integrating Matplotlib visualizations with a QML frontend in an APK?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved