Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. First Qt Python project
QtWS25 Last Chance

First Qt Python project

Scheduled Pinned Locked Moved Unsolved Qt for Python
16 Posts 6 Posters 2.6k 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.
  • A Anonymous_Banned275

    @JonB Bad guess... I did follow the "new program" and usied "Python" option. Easy to verify - it builds "python project" .
    If I can add to your guess - my is guess is - Qt is not doing full job on building the python code.
    I am still looking for reasonable tutorial for "how to build python app using QtCreator".
    All I have seen so far is not using QtCreator.
    But another guess - from very limited experience with Python code -
    there is NO need for "python project" - that is an add of QtCreator and not what I expected , NOT "ready to run".

    Cheers

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #6

    @AnneRanch Does it only happen if you try to add a slot to a widget?

    A 1 Reply Last reply
    0
    • JonBJ JonB

      @AnneRanch Does it only happen if you try to add a slot to a widget?

      A Offline
      A Offline
      Anonymous_Banned275
      wrote on last edited by
      #7

      @JonB Yes, I am trying to learn / build a simple project and that is only GUI I have added .
      BTW
      I added the "missing file" , it shows in "python project" , but it is still missing...

      JonBJ 1 Reply Last reply
      0
      • A Anonymous_Banned275

        @JonB Yes, I am trying to learn / build a simple project and that is only GUI I have added .
        BTW
        I added the "missing file" , it shows in "python project" , but it is still missing...

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #8

        @AnneRanch
        So like I said, that seems not to work for Python. If it is looking for .h file that should only be for C++. I don't know if that's a bug or just not supported.

        1 Reply Last reply
        0
        • A Anonymous_Banned275

          EDIT / UPDATE

          OK, I am little familiar with uic process ( converting ui to py ), question remains HOW and WHERE to execute this "command" . As written is has to be done in folder where "from.ui" resides....

          Does Qt has a simple way to accomplish this ?

          I would not call running this "command" using terminal simple...
          been there , done that running terminal command...is not simple process in Qt. ( of course your opinion will vary from mine , but that does not help solving the issuer.

          # Important:
          # You need to run the following command to generate the ui_form.py file
          #     pyside6-uic form.ui -o ui_form.py, or
          #     pyside2-uic form.ui -o ui_form.py
          

          After adding push button "slot" -> clicked ` I get this,
          "missing ui_form.h".

          All I did is add "main widget" with some widgets , and included plain "pushbutton" .

          What is this missing "ui_form.h"?

          Please - only constructive suggestion / solutions - no AI referral AKA "read Hello word ".

          I am starting from scratch and expect (?) basic code to work.

          Adding slots in C++ works , why it fails in Python?

          3a5aa0fa-8116-4bf1-99a1-0fe06837723c-image.png

          PS
          For the AI pedants here - rebuilding (the project) did not work , hence my post ...duh

          K Offline
          K Offline
          kkyzivat
          wrote on last edited by kkyzivat
          #9

          @AnneRanch I'm pretty sure this is an issue of Qt Designer/Qt Creator not having the python support needed for this feature, but I'm not 100% sure.

          The basic Qt for Python examples provided definitely work, and there is some basic support for Qt for Python in Qt Creator (syntax highlighting, creating "project" files, and a few others), but Qt Creator support for Python certainly could use some work.

          @CristianMaureira - is there support for this feature with Qt for Python apps in Qt Designer?

          To clarify: Qt Designer is the visual component designer piece of Qt Creator. Qt Creator is the larger app that allows you to create new projects, add new files, edit code, build, etc. Qt Creator has basic support for Python. The question is - does the designer piece have python support? Based on your experiences, it sounds like it doesn't.

          JonBJ 1 Reply Last reply
          0
          • K kkyzivat

            @AnneRanch I'm pretty sure this is an issue of Qt Designer/Qt Creator not having the python support needed for this feature, but I'm not 100% sure.

            The basic Qt for Python examples provided definitely work, and there is some basic support for Qt for Python in Qt Creator (syntax highlighting, creating "project" files, and a few others), but Qt Creator support for Python certainly could use some work.

            @CristianMaureira - is there support for this feature with Qt for Python apps in Qt Designer?

            To clarify: Qt Designer is the visual component designer piece of Qt Creator. Qt Creator is the larger app that allows you to create new projects, add new files, edit code, build, etc. Qt Creator has basic support for Python. The question is - does the designer piece have python support? Based on your experiences, it sounds like it doesn't.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #10

            @AnneRanch
            To be clear: Designer should have no support, either for C++ or for Python. It's only job is to create a .ui file (which is XML) describing the elements designed. Then

            • For C++ you run uic to pre-process the .ui to produce a ui_....h file. That should then be #included into one of your source C++ files.
            • For Python you run pyside6-uic / uic -python or equivalent to pre-process the .ui to produce a ui_....py file. That should then be imported into one of your source Python files.

            The error message you show comes from Creator. In some shape or form it is trying to access the generated ui_....h file to find or add a slot for the pushbutton selected in Designer. But since you are Python not C++ it's not going to find it. Why Creator is doing this in response to whatever you did I do not know.

            You are not alone in this. https://www.qtcentre.org/threads/71236-Python-QT5-Creator, for example, reports exactly the same from Python when

            If you go to form.ui and try to add a clicked slot to the button clicked(), an error appears that the "could not find documents matching ui-form.h / Perhaps rebuilding will help"

            with no resolution. And just the same in https://stackoverflow.com/questions/65605978/python-qtcreator-and-slots.

            So if this is so, and it's not some misconfiguration for Python in Creator/your project, then as I said I suggest it's a bug, and you will have not to try to access slot code from Creator/Designer.

            S 1 Reply Last reply
            2
            • JonBJ JonB

              @AnneRanch
              To be clear: Designer should have no support, either for C++ or for Python. It's only job is to create a .ui file (which is XML) describing the elements designed. Then

              • For C++ you run uic to pre-process the .ui to produce a ui_....h file. That should then be #included into one of your source C++ files.
              • For Python you run pyside6-uic / uic -python or equivalent to pre-process the .ui to produce a ui_....py file. That should then be imported into one of your source Python files.

              The error message you show comes from Creator. In some shape or form it is trying to access the generated ui_....h file to find or add a slot for the pushbutton selected in Designer. But since you are Python not C++ it's not going to find it. Why Creator is doing this in response to whatever you did I do not know.

              You are not alone in this. https://www.qtcentre.org/threads/71236-Python-QT5-Creator, for example, reports exactly the same from Python when

              If you go to form.ui and try to add a clicked slot to the button clicked(), an error appears that the "could not find documents matching ui-form.h / Perhaps rebuilding will help"

              with no resolution. And just the same in https://stackoverflow.com/questions/65605978/python-qtcreator-and-slots.

              So if this is so, and it's not some misconfiguration for Python in Creator/your project, then as I said I suggest it's a bug, and you will have not to try to access slot code from Creator/Designer.

              S Offline
              S Offline
              StarterKit
              wrote on last edited by StarterKit
              #11

              @JonB , just one small correction - starting from Qt 6.x you don't have pyside-uic anymore - you should use pure uic for both C++ and Python. But for python you should run it as uic -g python (actually we already explained it to @AnneRanch in parallel thread about external tools in PyCharm).

              With regards to Qt Designer and Python usage together - here is an article - it is a bit outdated but gives a sense of the context.

              CristianMaureiraC 1 Reply Last reply
              0
              • A Offline
                A Offline
                Anonymous_Banned275
                wrote on last edited by Anonymous_Banned275
                #12

                @kkyzivat
                POSTED BEFORE reading most recent responses.
                Since majority of "arguments" are mostly differences of opinions , thus seldom based on facts - here is an exception - my opinion based on facts. I can access Qt Python options (fact) and run "Python project" (fact) and I expect it to work. If it does not work (fact)- Qt vendor should remove Python option (opinion) .

                A 1 Reply Last reply
                0
                • A Anonymous_Banned275

                  @kkyzivat
                  POSTED BEFORE reading most recent responses.
                  Since majority of "arguments" are mostly differences of opinions , thus seldom based on facts - here is an exception - my opinion based on facts. I can access Qt Python options (fact) and run "Python project" (fact) and I expect it to work. If it does not work (fact)- Qt vendor should remove Python option (opinion) .

                  A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on last edited by
                  #13

                  @AnneRanch ...and after reading the last few posts ... this is getting off the subject (finding a solution ) and if there are no objections - PLEASE consider this thread closed.

                  My , hopefully temporary conclusion, is -
                  Qt Creator is not what one would use to build his /hers first Python project - caveat emptor .

                  CristianMaureiraC 1 Reply Last reply
                  0
                  • S StarterKit

                    @JonB , just one small correction - starting from Qt 6.x you don't have pyside-uic anymore - you should use pure uic for both C++ and Python. But for python you should run it as uic -g python (actually we already explained it to @AnneRanch in parallel thread about external tools in PyCharm).

                    With regards to Qt Designer and Python usage together - here is an article - it is a bit outdated but gives a sense of the context.

                    CristianMaureiraC Offline
                    CristianMaureiraC Offline
                    CristianMaureira
                    wrote on last edited by
                    #14

                    @StarterKit Sorry if it was not clear with all the release messages. pyside6-uic is still the recommended tool, because it uses the uic binary we include in the wheel. Encouraging people to use uic will cause problems because they might have another version installed in the system.

                    1 Reply Last reply
                    1
                    • A Anonymous_Banned275

                      @AnneRanch ...and after reading the last few posts ... this is getting off the subject (finding a solution ) and if there are no objections - PLEASE consider this thread closed.

                      My , hopefully temporary conclusion, is -
                      Qt Creator is not what one would use to build his /hers first Python project - caveat emptor .

                      CristianMaureiraC Offline
                      CristianMaureiraC Offline
                      CristianMaureira
                      wrote on last edited by CristianMaureira
                      #15

                      @AnneRanch this has been a long standing issue, mainly on how we can connect the designer capabilities with Python, at the moment with newer QtCreator versions, when you press "run" we run pyside6-project which detects any .ui file and runs pyside6-uic on them, and the same with .qrc files and pyside6-rcc so people don't need to worry about it.

                      The good thing is that in the last couple of days there was an agreement between QtCreator and Qt for Python PMs to create a roadmap to get a full support in QtCreator.

                      You are completely right that if you open a Python project, and you click any button or select any option things should work, the problematic bit is that QtCreator is an IDE that was not built with the use cases of other languages, so we need to work hard on trying to see how we can massage the current options for Python users.
                      Even the main concept of "a kit" is somehow not needed for Python users, but they still need to work around to get that configuration with some values that make sense.

                      I cannot tell you @AnneRanch what would be the future options, or use-cases, because it's something that's being defined. There has been lots of improvements in QtCreator since Qt for Python was released, and connecting more functionalities with Designer is still an open one.
                      Because you are currently using, I'd encourage you to help the project by filing as many bugs as you encounter, because we are not considering all uses cases, mainly to have a bias developer point of view.

                      Hopefully we can address the go-to-slot issue, which was raised some time ago by another user and we haven't managed to figure out :)

                      1 Reply Last reply
                      2
                      • A Offline
                        A Offline
                        Anonymous_Banned275
                        wrote on last edited by
                        #16

                        I do appreciate you taking time for reply.
                        However, you may not be aware that what I was trying to do is not
                        “normal”. As a user of C++ QtCreator /QtDesiger I did expected that I can modify existing Python application using QtDesigner. That just did not work and it is not a “big deal” ( to me) that it does not.

                        There are other Qt issues which could use some attention and hopefully a resolution.
                        However, I feel this is is not the place to discuss that, and most of them have been “reported” as bug(s) anyway.

                        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