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. Promoting a widget in Qt Designer
Forum Updated to NodeBB v4.3 + New Features

Promoting a widget in Qt Designer

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 700 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.
  • krzysieklfcK Offline
    krzysieklfcK Offline
    krzysieklfc
    wrote on last edited by krzysieklfc
    #1

    I want to promote QWidget to custom widget derived from it. The problem is that the widget expects more arguments to be passed to the constructor and in the generated ui_ file only the parent is passed:

    //constructor is:  QmaxRollup (int category=ROLLUP_CAT_STANDARD, QWidget *parent=nullptr)
    //generated:
    widget_1 = new MaxSDK::QmaxRollup(Form);
    

    error C2664: 'MaxSDK::QmaxRollup::QmaxRollup(const MaxSDK::QmaxRollup &)': cannot convert argument 1 from 'QWidget *' to 'int'

    The documentation says:
    [...] It exposes properties such as title and category, so they can be easily set in code or in the Qt Designer.

    I already set dynamic properties to the widget in my form, but it doesn't change anything.
    0_1558718982901_1.jpg
    Header file is available here.

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

      Hi,

      What you can do is initialise category directly in the constructor with the ROLLUP_CAT_STANDARD value and add a setter to your class to modify that property.

      You can then do that in your code somewhere more suitable.

      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
      2
      • krzysieklfcK Offline
        krzysieklfcK Offline
        krzysieklfc
        wrote on last edited by
        #3

        Hello,

        Thanks for answer

        The class is implemented in static library so I don't think I can cleanly change the source code. I'm just wondering if I can initialize it directly in form to keep things consistent.
        If not, I can always add the widget to the UI after the form is created.

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

          Whether it's a dynamic or static library doesn't really matter. If you have control on it, you can modify the widget and rebuild the library.

          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
          1

          • Login

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