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
QtWS25 Last Chance

Uİ Form Using Promote Class

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 378 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.
  • NevezN Offline
    NevezN Offline
    Nevez
    wrote on 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

    Pl45m4P 1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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
      • NevezN Offline
        NevezN Offline
        Nevez
        wrote on last edited by Nevez
        #3
        This post is deleted!
        Christian EhrlicherC 1 Reply Last reply
        0
        • NevezN Nevez

          This post is deleted!

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 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
          • NevezN Offline
            NevezN Offline
            Nevez
            wrote on 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

            Christian EhrlicherC 1 Reply Last reply
            0
            • NevezN Nevez

              @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

              Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 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
              • NevezN Nevez

                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

                Pl45m4P Online
                Pl45m4P Online
                Pl45m4
                wrote on last edited by Pl45m4
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • NevezN Offline
                  NevezN Offline
                  Nevez
                  wrote on 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

                  • Login

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