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. Promote To... button
Qt 6.11 is out! See what's new in the release blog

Promote To... button

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.4k 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.
  • F Offline
    F Offline
    Flurite
    wrote on last edited by
    #1

    When you want to create a custom widget and form a class out of it, one should use the "Promote To..." option, which allows you to promote it to a custom class.

    How does this work? Does the widget still retain all it's properties? What changes in this process?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      This is for using widgets that don't provide a QtDesigner plugin in projects that use .ui files (QtDesigner files). So you add the base class (e.g. QWidget) in QtDesigner and promote it to the subclass. All this changes is what class name is used in the generated code file and thus what class gets instantiated during runtime. Nothing changes in QtDesigner, though.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Flurite
        wrote on last edited by
        #3

        How does it change its class? Shouldn't the properties change as well then?

        Does the widget still retain properties of a regular widget? Does it gain properties of the class it becomes? Does it change the class itself?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          scroverty
          wrote on last edited by
          #4

          bq. Does the widget still retain properties of a regular widget?

          Yes, as DerManu said, nothing changes in QtDesigner, which it will still be a widget.

          bq. Does it gain properties of the class it becomes?

          Absolutely, else, this process won't be called "promote", wouldn't it?

          bq. Does it change the class itself?

          Pretty yes. The new class should gain the funtion defined inside the header file you created.

          Alvis Ar'Berkeley Andrew.
          Pleased to meet you!

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Flurite
            wrote on last edited by
            #5

            So I promoted a widget to a class called mypanelopengl.h, but I didn't see a new function in the class. Does it only happen when I build the project, or am I doing something wrong?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DerManu
              wrote on last edited by
              #6

              [quote author="Flurite" date="1346021970"]So I promoted a widget to a class called mypanelopengl.h, but I didn't see a new function in the class. Does it only happen when I build the project, or am I doing something wrong?[/quote]

              Does the header file mypanelopengl.h exist and contain a class with new functions?

              What means that you didn't "see" a new function?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                scroverty
                wrote on last edited by
                #7

                [quote author="Flurite" date="1346021970"]So I promoted a widget to a class called mypanelopengl.h, but I didn't see a new function in the class. Does it only happen when I build the project, or am I doing something wrong?[/quote]

                I think you're talking about auto-complete for the funtion inside that header?

                Try open the file with QtCreator?

                Alvis Ar'Berkeley Andrew.
                Pleased to meet you!

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Flurite
                  wrote on last edited by
                  #8

                  I think I am confused about what A.A.B.A said here:

                  bq.
                  Pretty yes. The new class should gain the funtion defined inside the header file you created.

                  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