Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, January 2007
QDataWidgetMapper:please help


Message 1 in thread

I am trying to create a data aware form by using QDataWidgetMapper, my data is coming from a database and i am trying to apply a QSqlDataModel to the mapper using setmodel():
 
QDataWidgetMapper *mapper = new QDataWidgetMapper();
mapper->setModel(model);
 
where 'model' is the qsqldatamodel, but i'm getting the following error and i would like to know how i can achieve what i am trying to do
 
error:  d:\db_access\edit_user.cpp(12): error C2664: 'QDataWidgetMapper::setModel' : cannot convert parameter 1 from 'QSqlTableModel' to 'QAbstractItemModel *'
i understand that setmodel() requires a argument of type QAbstractItemModel, but the model i would like to use is the QSqlDataModel, any help would be appreciated. thanks very much for your attention.
 
_________________________________________________________________
Fixing up the home? Live Search can help.
http://imagine-windowslive.com/search/kits/default.aspx?kit=improve&locale=en-US&source=wlmemailtaglinenov06

Message 2 in thread

Thanks for the heads up Bill.The error went away. I appreciate the help.
 
Can anyone help me with QDataWidgetMapper?
 
But now the mapping is not working, i am trying a very simple piece of code i got from the documentation but i am not able to see the data in my table. The code is as follows:
 
QSqlTableModel *model = new QSqlTableModel(this);
model->setTable("user_info");

QDataWidgetMapper *mapper = new QDataWidgetMapper();
mapper->setModel(model);
mapper->addMapping(comboBox, 0);
mapper->addMapping(lineEdit_2, 1);
mapper->addMapping(lineEdit_3, 2);
mapper->addMapping(lineEdit_4, 3);
mapper->addMapping(lineEdit_5, 4);
//mapper->setOrientation(Qt::Vertical);
connect(pushButton,SIGNAL(clicked()),mapper,SLOT(toNext()));
 
I created a form with the widgets above (lineEdit, combobox ect) and created a class which inherits the form class, what i have above is an extract form the constructor for my derived class. But when the programm runs i see nothing in the widgets. I saw in the archive where someone else was having problems with it but no one responded to him. But i see others saying they are able to use it, if you can give me an example of how to make it work that would be great. Thanks in advance.




> Date: Thu, 18 Jan 2007 11:21:05 +1000> From: bill.king@xxxxxxxxxxxxx> To: jrkeith95@xxxxxxxxxxx> Subject: Re: QDataWidgetMapper:please help> > keith burke wrote:> > *I am trying to create a data aware form by using *QDataWidgetMapper,> > my data is coming from a database and i am trying to apply> > a QSqlDataModel to the mapper using setmodel():> > > > QDataWidgetMapper *mapper = new QDataWidgetMapper();> > mapper->setModel(model);> > > > where 'model' is the qsqldatamodel, but i'm getting the following> > error and i would like to know how i can achieve what i am trying to do> > > > error: d:\db_access\edit_user.cpp(12): error C2664:> > 'QDataWidgetMapper::setModel' : cannot convert parameter 1 from> > 'QSqlTableModel' to 'QAbstractItemModel *'> >> > i understand that setmodel() requires a argument of type> > QAbstractItemModel, but the model i would like to use is the> > QSqlDataModel, any help would be appreciated. thanks very much for> > your attention.> > > >> > ------------------------------------------------------------------------> > View Athletes' Collections with Live Search. See it!> > <http://sportmaps.live.com/index.html?source=wlmemailtaglinenov06>> You're passing an instance and not a pointer. It's trying to tell you to> declare model as QSqlDataModel *model=new QSqlDataModel(...)> > Hope this helps.> > -- > Bill King, Software Engineer> Trolltech, Brisbane Technology Park> 26 Brandl St, Eight Mile Plains, > QLD, Australia, 4113> Tel + 61 7 3219 9906 (x137)> Fax + 61 7 3219 9938> mobile: 0423 532 733> 
_________________________________________________________________
Get the Live.com Holiday Page for recipes, gift-giving ideas, and more.
www.live.com/?addtemplate=holiday