Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What is the best way to implement a custom widget in an application?

What is the best way to implement a custom widget in an application?

Scheduled Pinned Locked Moved Solved General and Desktop
customplugincustom widgetgui developmentapplication
4 Posts 2 Posters 1.7k 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
    Sh1gs
    wrote on 27 Jun 2017, 15:20 last edited by
    #1

    Hello,

    I was wondering what the best way to use a custom plugin in an application is? I have created a custom IP Editor plugin. I built my plugin, which created a .dll. I have added the .dll to the Qt/plugins/designer folder. In my application .pro I have include(ipeditor.pri) In my application .cpp file, I am creating the widget by doing something like:

    IPEditor *ipeditor = new IPEditor(this);
    

    I then add the widget to a layout and continue on with other parts of the project. This seems to work fine, if it's the only widget being added to the application. I seem to have crash issues if I try adding it to an application that contains pages, stacked widgets, etc. But that's another issue for another day. I was wondering if there was a better way to add a custom plugin? I've read about the UILoader, but I am confused of how that works exactly. Can anyone shed some light on this? Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 27 Jun 2017, 15:41 last edited by
      #2

      Hi
      For a designer plugin, using a .pri file is the way to go.
      But if you are not adding it via Designer, why did you make it a plugin ?

      When im not needing design time editing of a custom widget, i just use promotion.
      http://doc.qt.io/qt-4.8/designer-using-custom-widgets.html
      That way i dont have to make plugin/dll and all that stuff and can simply use the custom widget.

      If you crash with other combinations of widgets , you most likely have some sort of bug.

      S 1 Reply Last reply 27 Jun 2017, 16:17
      0
      • M mrjj
        27 Jun 2017, 15:41

        Hi
        For a designer plugin, using a .pri file is the way to go.
        But if you are not adding it via Designer, why did you make it a plugin ?

        When im not needing design time editing of a custom widget, i just use promotion.
        http://doc.qt.io/qt-4.8/designer-using-custom-widgets.html
        That way i dont have to make plugin/dll and all that stuff and can simply use the custom widget.

        If you crash with other combinations of widgets , you most likely have some sort of bug.

        S Offline
        S Offline
        Sh1gs
        wrote on 27 Jun 2017, 16:17 last edited by
        #3

        Hello @mrjj

        Adding it within the code is a requirement for testing where I work, but I also need to be able to add it via designer which is why I make it a plugin. We ultimately don't know which route the end user is going to go with it, so we give them the option.

        I will make another topic post about the crash and go ahead and mark this as solved. Thanks!

        M 1 Reply Last reply 27 Jun 2017, 16:28
        0
        • S Sh1gs
          27 Jun 2017, 16:17

          Hello @mrjj

          Adding it within the code is a requirement for testing where I work, but I also need to be able to add it via designer which is why I make it a plugin. We ultimately don't know which route the end user is going to go with it, so we give them the option.

          I will make another topic post about the crash and go ahead and mark this as solved. Thanks!

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 27 Jun 2017, 16:28 last edited by
          #4

          @Sh1gs
          Just as a note.
          There is no difference adding widgets in code or adding via Designer.
          The setupUI() as seen in mainwindow ctor creates the Designer widgets as code.

          So the only true difference is handwritten versus generated from UI file.
          Also adding via Designer, gives easier translations as the translate function is generated for the user.

          1 Reply Last reply
          0

          3/4

          27 Jun 2017, 16:17

          • Login

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