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. Reuse Qt UI class [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

Reuse Qt UI class [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
qtcreatordesigner
7 Posts 3 Posters 2.8k 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
    sachi
    wrote on last edited by sachi
    #1

    I am new to Qt. I have created user class with gui form. now I want to extend this class to Employee class. i need add section for reset password. Is it possible in Qt. I am using Qt 5.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      In general you can reuse ui files in other classes; if you paste some code we could help you in a better way

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      S 1 Reply Last reply
      0
      • S Offline
        S Offline
        sachi
        wrote on last edited by
        #3

        I have files user.cpp user.h user.ui, this class is used show then user's details on application. now i want to extend this class to employee. employee class have password reset fuction additionally. In employe ui file it must have textfield for password. all other are same as user class. now i want to use user.ui form to create employee.ui form. just want to add some textfield additionally.

        1 Reply Last reply
        0
        • M mcosta

          Hi and welcome to devnet,

          In general you can reuse ui files in other classes; if you paste some code we could help you in a better way

          S Offline
          S Offline
          sachi
          wrote on last edited by
          #4

          @mcosta I want to extend ui and C++ class together. if this possible in qt?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            ChrisW67
            wrote on last edited by
            #5

            There is no inheritance of UI xml files, and the generated form classes in the Ui:: namespace reflect this.

            A few approaches:

            • Build a single form containing everything for the employee case and use that UI in both C++ classes. In the UserForm class setup the UI and hide the Employee extra widgets, and in the EmployeeForm set up the UI and just use the form as-is.
            • Build a single form containing everything for the employee case and use that UI in a single C++ class that can be constructed in two modes. In one mode hide the extra widgets.
            • Build a single form containing only the UserForm widgets. Use that form in both classes but in the EmployeeForm class programmtically add more widgets to the UI.
            S 2 Replies Last reply
            1
            • C ChrisW67

              There is no inheritance of UI xml files, and the generated form classes in the Ui:: namespace reflect this.

              A few approaches:

              • Build a single form containing everything for the employee case and use that UI in both C++ classes. In the UserForm class setup the UI and hide the Employee extra widgets, and in the EmployeeForm set up the UI and just use the form as-is.
              • Build a single form containing everything for the employee case and use that UI in a single C++ class that can be constructed in two modes. In one mode hide the extra widgets.
              • Build a single form containing only the UserForm widgets. Use that form in both classes but in the EmployeeForm class programmtically add more widgets to the UI.
              S Offline
              S Offline
              sachi
              wrote on last edited by
              #6

              @ChrisW67 thank you for your help. it was very helpful. i will try your solutions.

              1 Reply Last reply
              0
              • C ChrisW67

                There is no inheritance of UI xml files, and the generated form classes in the Ui:: namespace reflect this.

                A few approaches:

                • Build a single form containing everything for the employee case and use that UI in both C++ classes. In the UserForm class setup the UI and hide the Employee extra widgets, and in the EmployeeForm set up the UI and just use the form as-is.
                • Build a single form containing everything for the employee case and use that UI in a single C++ class that can be constructed in two modes. In one mode hide the extra widgets.
                • Build a single form containing only the UserForm widgets. Use that form in both classes but in the EmployeeForm class programmtically add more widgets to the UI.
                S Offline
                S Offline
                sachi
                wrote on last edited by
                #7

                @ChrisW67 i have tried your solution i have created user class and employee class by extending user class. but i can't access user class widgets. i have defined them as protected. can you show me correct way to do it?

                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