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. How to create custom widget plugin for Qt Designer with Qt for Python?
Forum Updated to NodeBB v4.3 + New Features

How to create custom widget plugin for Qt Designer with Qt for Python?

Scheduled Pinned Locked Moved Solved Qt for Python
pyside2qt for python
4 Posts 3 Posters 3.3k Views 1 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.
  • S Offline
    S Offline
    StarterKit
    wrote on 27 Feb 2021, 11:36 last edited by
    #1

    Hi,
    I'm using Qt for python as it was a low hanging fruit to make my small application working on Windows, Linux and MacOS (this is why I'm not interested in a C-based solution).

    I created several custom UI-widgets. And then I used "Promote to..." feature of Qt Designer to incorporate them in my forms. It works but I see that it brings me extra code that does only correct placement and alignment of layouts. It would be definitely better to get rid of this code and give this job to Qt Designer and auto-generated code. I.e. incorporate my custom widget into Qt Designer instead of usage of widget promotion.

    So, I started to search a way to create custom widget plugin for Qt Designer and found only 2 sources of information:

    • The page in Qt documentation - but I see it describes the process for C++ and use some compiler/linker flags. So I don't understand how to apply the same in python
    • An old article in Qt Quaterly - it describes the process for PyQt4 and looks quite stright-forward. But... it seems to be outdated. At least I can't find class QPyDesignerCustomWidgetPlugin for example to derive my custom plugin from it.

    So, my question is - is it possible to create custom widget plugin for Qt Designer with pure PySide2/PySide6?

    J 1 Reply Last reply 27 Feb 2021, 11:49
    1
    • S Offline
      S Offline
      Shyamnath
      wrote on 3 Mar 2022, 13:37 last edited by
      #4

      For anyone searching for the same thing. It is now possible with Qt for Python to create a QtDesigner plugin in Python:
      https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#custom-widgets-in-qt-designer

      1 Reply Last reply
      2
      • S StarterKit
        27 Feb 2021, 11:36

        Hi,
        I'm using Qt for python as it was a low hanging fruit to make my small application working on Windows, Linux and MacOS (this is why I'm not interested in a C-based solution).

        I created several custom UI-widgets. And then I used "Promote to..." feature of Qt Designer to incorporate them in my forms. It works but I see that it brings me extra code that does only correct placement and alignment of layouts. It would be definitely better to get rid of this code and give this job to Qt Designer and auto-generated code. I.e. incorporate my custom widget into Qt Designer instead of usage of widget promotion.

        So, I started to search a way to create custom widget plugin for Qt Designer and found only 2 sources of information:

        • The page in Qt documentation - but I see it describes the process for C++ and use some compiler/linker flags. So I don't understand how to apply the same in python
        • An old article in Qt Quaterly - it describes the process for PyQt4 and looks quite stright-forward. But... it seems to be outdated. At least I can't find class QPyDesignerCustomWidgetPlugin for example to derive my custom plugin from it.

        So, my question is - is it possible to create custom widget plugin for Qt Designer with pure PySide2/PySide6?

        J Offline
        J Offline
        JonB
        wrote on 27 Feb 2021, 11:49 last edited by
        #2

        @StarterKit
        think you should read https://stackoverflow.com/questions/52128188/using-a-custom-pyside2-widget-in-qt-designer. Though it has a strangely unterminated answer from @eyllanesc , who visits this forum and may see this post....

        My impression is that you need to stick with Promotion. Designer custom widget may be possible from PyQt, but not from PySide.

        application working on Windows, Linux and MacOS (this is why I'm not interested in a C-based solution).

        You may have your own good reasons for wanting to use Python, but I don't know what you are implying here. A C++ solution would indeed work, and allow custom widget design for use in Designer, across all these platforms.

        S 1 Reply Last reply 27 Feb 2021, 13:05
        0
        • J JonB
          27 Feb 2021, 11:49

          @StarterKit
          think you should read https://stackoverflow.com/questions/52128188/using-a-custom-pyside2-widget-in-qt-designer. Though it has a strangely unterminated answer from @eyllanesc , who visits this forum and may see this post....

          My impression is that you need to stick with Promotion. Designer custom widget may be possible from PyQt, but not from PySide.

          application working on Windows, Linux and MacOS (this is why I'm not interested in a C-based solution).

          You may have your own good reasons for wanting to use Python, but I don't know what you are implying here. A C++ solution would indeed work, and allow custom widget design for use in Designer, across all these platforms.

          S Offline
          S Offline
          StarterKit
          wrote on 27 Feb 2021, 13:05 last edited by
          #3

          @JonB said in How to create custom widget plugin for Qt Designer with Qt for Python?:

          You may have your own good reasons for wanting to use Python, but I don't know what you are implying here. A C++ solution would indeed work, and allow custom widget design for use in Designer, across all these platforms.

          Ok, I see that I put it in unclear way. I meant to say I already have several different widgets created with python and don't wish to re-write them in C++. I agree with you that I may re-create it with C++ and it will work but I really don't wish to do it.

          Thanks for the link to stackoverflow, I'll take a look there. Promotion works good but it's not so comfortable to fine-tune placement of different parts in UI - this is why I'm looking for other possible options.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Shyamnath
            wrote on 3 Mar 2022, 13:37 last edited by
            #4

            For anyone searching for the same thing. It is now possible with Qt for Python to create a QtDesigner plugin in Python:
            https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#custom-widgets-in-qt-designer

            1 Reply Last reply
            2
            • S StarterKit has marked this topic as solved on 23 Feb 2023, 13:48

            • Login

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