views:

74

answers:

3

So I try to build a Model-View window using QTDesigner and C++.

For that reason I created a QOBject derived class as my model. It provides slots and signals to access it like: setFileName(QString) or fileNameChanged(QString).

I got a little into using signal drag and drop in QTDesigner and found it quite VA-Smalltalk-Like nice. After a while I was wondering if I could also connect my model to this. So is it possible to somehow introduce my model object into the Window/GUI and let QTDesigner connect signals and slots from the model object to the GUI.

In essence: Write for me:

connect( model, SIGNAL(fileNameChanged(QString)), ui->labelFn, SLOT(setText(QString)))
connect( ui-textEdit2, SIGNAL(textChanged(QString)), model, SLOT(setFileName(QString)))

Thanks for explaining

A: 

This probably a duplicate to this question.

jopa
I read that before, but i found my situation different. Maybe I'm wrong
Robert0
@RobertO AFAIK, to propagate your model's properties/slots to the designer, you must provide it in a plugin.
jopa
A: 

The only way to introduce new types of objects into Designer is via a plugin, but that only works for widgets, via QDesignerCustomWidgetCollectionInterface. It would be nice if Designer allowed connections to other objects just like Apple’s Interface Builder allows, but it is not possible. For now, we are left connecting such signals in the form’s constructor.

andref
A: 

As jopa said, if you want to do it in the Designer, you need to make the Designer aware of your component, which is probably only worthwhile if it is something you will reuse often. IMHO, the Designer is great for prototyping or creating an initial UI design, but not so good for long term maintenance. Although, the Designer is very powerful, there are a number of options that aren't exposed through the interface.

I suggest looking into the Qt's auto-connect capabilities. It attempts to make connection purely through a slot naming convention. Read more here. I've been itching to try this out, but we are only just getting into our Qt 4 conversion project and I haven't had a chance yet.

Chris Morlier