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. Uİ Form Using Promote Class
Forum Updated to NodeBB v4.3 + New Features

Uİ Form Using Promote Class

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 419 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.
  • N Offline
    N Offline
    Nevez
    wrote on 31 Mar 2022, 11:51 last edited by Nevez
    #1

    Hi,
    I have a combobox class that I derived from qcombobox. The constructor of this class takes QAbstractItemModel as a parameter. When I run it from the code side and not from the ui side, it works fine. However, I get an error when I derive a combobox that I have already created in the Ui form in my own combobox class. I know the problem is Qabstracitemmodel in Constructor. But I have to use this parameter. How can I create a solution as an alternative?
    MyCombobox Constructor

     MyComboBox(QAbstractItemModel *model,QWidget *parent = nullptr);
    

    The part of the code where the mainwindow.ui fails.

    comboBox = new myComboBox(centralwidget); // Error
    

    I need to promote it somehow

    P 1 Reply Last reply 31 Mar 2022, 12:41
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 31 Mar 2022, 11:52 last edited by
      #2

      This does not work - you need a ctor which takes a QWidget *parent only - the rest has to be done later in your code.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Nevez
        wrote on 31 Mar 2022, 12:12 last edited by Nevez
        #3
        This post is deleted!
        C 1 Reply Last reply 31 Mar 2022, 12:18
        0
        • N Nevez
          31 Mar 2022, 12:12

          This post is deleted!

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 31 Mar 2022, 12:18 last edited by
          #4

          @Nevez said in Uİ Form Using Promote Class:

          I need to pass QSqlquerymodel as a parameter to the constructor of another validator class inside my mycombobox constructor

          Then don't do this and move it out into a separate init() - function.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • N Offline
            N Offline
            Nevez
            wrote on 31 Mar 2022, 12:28 last edited by
            #5

            @Christian-Ehrlicher said in Uİ Form Using Promote Class:

            Then don't do this and move it out into a separate init() - function.

            this is not helping me.
            I need to keep all properties like Validation,completed in my combobox class that I created.
            I have to create and set the DB connection outside of this class. Which is what I'm doing now, but I can't promote it only on the ui side

            C 1 Reply Last reply 31 Mar 2022, 12:30
            0
            • N Nevez
              31 Mar 2022, 12:28

              @Christian-Ehrlicher said in Uİ Form Using Promote Class:

              Then don't do this and move it out into a separate init() - function.

              this is not helping me.
              I need to keep all properties like Validation,completed in my combobox class that I created.
              I have to create and set the DB connection outside of this class. Which is what I'm doing now, but I can't promote it only on the ui side

              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 31 Mar 2022, 12:30 last edited by
              #6

              @Nevez said in Uİ Form Using Promote Class:

              but I can't promote it only on the ui side

              I don't see why not.
              Create a ctor which only take a QWidget parent and an init() - function where you do all your stuff which you're doing in your ctor and needs the addtional parameter and call this init function later on.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              3
              • N Nevez
                31 Mar 2022, 11:51

                Hi,
                I have a combobox class that I derived from qcombobox. The constructor of this class takes QAbstractItemModel as a parameter. When I run it from the code side and not from the ui side, it works fine. However, I get an error when I derive a combobox that I have already created in the Ui form in my own combobox class. I know the problem is Qabstracitemmodel in Constructor. But I have to use this parameter. How can I create a solution as an alternative?
                MyCombobox Constructor

                 MyComboBox(QAbstractItemModel *model,QWidget *parent = nullptr);
                

                The part of the code where the mainwindow.ui fails.

                comboBox = new myComboBox(centralwidget); // Error
                

                I need to promote it somehow

                P Offline
                P Offline
                Pl45m4
                wrote on 31 Mar 2022, 12:41 last edited by Pl45m4
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  Nevez
                  wrote on 31 Mar 2022, 13:59 last edited by
                  #8

                  @Christian-Ehrlicher said in Uİ Form Using Promote Class:

                  Yalnızca bir QWidget ebeveyni ve bir init() - ctor'unuzda yaptığınız tüm işlerinizi yaptığınız ve ek parametreye ihtiyaç duyan bir ctor oluşturun ve bu init işlevini daha sonra çağırın.

                  this idea led me to another idea for solution. It worked.
                  Thanks.

                  1 Reply Last reply
                  0

                  3/8

                  31 Mar 2022, 12:12

                  topic:navigator.unread, 5
                  • Login

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