Question

How would I go about passing QSqlQueryModel from a class that connects and queries the database through the control class or QMainWindow in my attempt and back to the widget needing the information?

I thought I could pass the reference location to the QSqlQueryModel object, but this is not working or I am doing something wrong.

I haven't found any examples showing what I am doing on the Qt Developer page.

Était-ce utile?

La solution

Looks like these are just compiler errors, nothing specifically to do with Qt.

In short you are getting your pointers and references mixed up.

Error #1:

cardList = new List(sqlModel->getListModel());

You are passing a reference when the List takes a pointer. Fix your return type from getListModel or fix the above line.

Next, you are not specifying the second argument, i.e. the parent QWidget. Either specify your MainWindow as the parent, pass 0, or fix your constructor's signature to provide a default (generally 0).

Error #2:

List::List(QSqlQueryModel *model, QWidget *parent) :  ListUI(parent){
    setListItems(&model);
}

You receive the model as a pointer and then attempted to take the address of the pointer. I.e. You're making a double pointer. Change the line to

setListItems(model);

Hope that helps.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top