Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Qt 5.8 + python3
Forum Updated to NodeBB v4.3 + New Features

Qt 5.8 + python3

Scheduled Pinned Locked Moved Unsolved Language Bindings
10 Posts 3 Posters 6.7k Views 3 Watching
  • 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.
  • C Offline
    C Offline
    ceora
    wrote on last edited by ceora
    #1

    Hi, all i'm trying to develop an application in c++ with the ability to scripting it through an add-on mechanism using python as language.

    The idea is to have the main interface, the textedtior, and the main interface component in c++
    the through python, users can interact with the editor, manipulating text trough QTextCursor, adding widgets and so on. Is this is possible? Is possible to create a widget in python and parenting it to an existing widget created with c++?? if so which is the correct Qt bind to achieve this??

    I've look at pythonqt, but it seems no longer supported(at last it doesn't support >Qt5.6)

    Instead I'dont understand if PyQt5 is only a bind without any c++ hybrid application same for PySide. I would like also use pybind11 for my class binds along with qt binds is this possible??

    Unfortunately on google i found only pure python qt usage and no c++/python hybrid.

    Thanks! and sorry for lot questions

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Something's not completely clear. You would like to be able to run complex python scripts possibly with modules like PyQt through your application and get them to talk together, is that correct ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ceora
        wrote on last edited by
        #3

        Yes, basically something like Sublime or Atom does: text manipulation, completition and TextEditor stuff like this plus the abilty to add widgets through python.
        In python i import the qt modules, the application modules(maybe created with pybind11) and use the provided api to access the application object instance and manipulate them.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          So embedding python like described here ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          the_T C 2 Replies Last reply
          0
          • SGaistS SGaist

            So embedding python like described here ?

            the_T Offline
            the_T Offline
            the_
            wrote on last edited by
            #5

            @SGaist

            Trying this runs into an error for me(python3.6 + Qt5.8 )

            
            #include "mainwindow.h"
            #include "ui_mainwindow.h"
            
            #include <python3.6m/Python.h>
            
            MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow)
            {
                ui->setupUi(this);
            
            
            }
            

            leads to

            /usr/include/python3.6m/object.h:448: error: expected unqualified-id before ‘;’ token
                 PyType_Slot *slots; /* terminated by slot==0. */
                                   ^
            

            -- No support in PM --

            1 Reply Last reply
            0
            • SGaistS SGaist

              So embedding python like described here ?

              C Offline
              C Offline
              ceora
              wrote on last edited by
              #6

              @SGaist
              Exactly, both extending, by providing my own api to python an embedding in order to execute the script when necessary on even at start up for gui.

              an example of usage could be like this:

              from myApp import Commands, ActionManager, TextEditor
              # is this necessary?
              from pyQt5 import .........
              # DuplicateLineUp inherit from commands so when python execute the script
              # this command is registered internally in c++(i suppose)
              # when the user call for exampl Ctrl +D, exec is called
              class DuplicateLineUp(Commands):
                  
                   def exec():
                          textEditor = TextEditor.activeTexteditor()
                          # now cursor is a Qt Object so I need PyQt or PySide??
                          cursor.moveToBeginOfLine()
                         # and so on
              

              another example that involve widgets

              from myApp import Workspace
              # again pyQt5 or pyside2???
              from pyQt5 import QTextEditor
              
              class MarkDownPreviewer(QTextEditor):
                       # subclass QTextEditor 
              
              # register the interface
              # call c++ api to split the central widget
              panel = Workspace.splitPanel(direction='right')
              # call c++ api to parenting the python created widget to
              # the c++ SplitView
              panel.setWidget(MarkDownPreviewer)       
              

              That's basically what i want to achieve. Currently I' don't know how.. I need to study further, but i need a direction and also the library that should do the work(and that's my question: since pythonQt seems the right choice, but ' it's not updated, does pyQt5 or pyside 2 work in an embedded/extended environment?? and if so how to get started?? I need i hybrd c++/python + Qt tutorial and not pure python app)

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @the_ You'll likely need to use CONFIG += no_keywords. Take a look at Using Qt with 3rd Party Signals and Slots.

                PySide and PyQt are just bindings to write Qt application directly in python. So indeed PythonQt looks exactly what you want to have.

                From the looks of the svn repository, the project is still active, the current last commit is from February 2017

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                the_T C 2 Replies Last reply
                2
                • SGaistS SGaist

                  @the_ You'll likely need to use CONFIG += no_keywords. Take a look at Using Qt with 3rd Party Signals and Slots.

                  PySide and PyQt are just bindings to write Qt application directly in python. So indeed PythonQt looks exactly what you want to have.

                  From the looks of the svn repository, the project is still active, the current last commit is from February 2017

                  the_T Offline
                  the_T Offline
                  the_
                  wrote on last edited by
                  #8

                  @SGaist
                  Must have missed this section. Thanks :)

                  -- No support in PM --

                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    @the_ You'll likely need to use CONFIG += no_keywords. Take a look at Using Qt with 3rd Party Signals and Slots.

                    PySide and PyQt are just bindings to write Qt application directly in python. So indeed PythonQt looks exactly what you want to have.

                    From the looks of the svn repository, the project is still active, the current last commit is from February 2017

                    C Offline
                    C Offline
                    ceora
                    wrote on last edited by ceora
                    #9

                    @SGaist unfortunately i've downloaded the source and tried to compile it but it gives me error about missing enumerator, if i don't get wrong is 'WindowCancelButtonHint', that in fact is missing from the last Qt version.. I'll post an issue on github on pythonQt and see.. So at the end it was the first thing i've thought.

                    Edit: it seems that github version is outdated, and from commits on sourceforge instead seems they fixed the missing enum

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      I've took a look at the official project on SourceForge so we may have something different currently.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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