Uİ Form Using Promote Class
-
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 ConstructorMyComboBox(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
-
This does not work - you need a ctor which takes a
QWidget *parent
only - the rest has to be done later in your code. -
@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.
-
@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 -
@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. -
@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.