Adding an inheritance to an Qt designed object
I have a problem and I want to implement the MVC pattern t开发者_JAVA百科o my QT application, that's why I need for example to inherite in my QTableWidget about another class like
myClass
{
myMethod();
}
but our QTableWidget is contained by our Mainwidows that is designed by the QT designer and generate an ui_MainWindow class !
Do you know how to do that ?
Is that a method inside the Qt Designer to do that ? or another method ?
Thank you for your answer !
You can use custom objects in QDesigner. Right click on the widget that you want to have as an instance of a something that is not available in designer and select "Promote to ...". In that dialog you can enter a custom class and a include file where the declaration for your class can be found.
BUT Qt implements uses MVC for a lot of the classes look at QTableView
as opposed to QTableWidget
, QTableView
uses QAbstractItemModel
as the model class and there is a pretty strict separation between the view and the model. See also An Introduction to Model/View Programming @ Nokia
精彩评论