Forum
Sign Up
× DataGrid for Qt.C++

How to access to the model from an editor?

12 years 1 week ago #1 by
Hi,
i want to make a custom editor for a combobox. For the items of the combobox i want to get form the data method of the model (Qt::UserRole) as a QStringList. Over the GridEditorSite i can get the ModelIndex, but how i can get the pointer to the model? Or do you have a better idea to fill the list of the combobox without using a relation model?

Please Log in or Create an account to join the conversation.

  • 's Avatar Topic Author
12 years 1 week ago - 12 years 1 week ago #2 by Developer Machines
QModelIndex has link to the model that hold it.
const QAbstractItemModel * QModelIndex::model() const.

Other way you can get the model reference from dataBinding:
site->dataBinding()->controller()->model().

Additionaly the dataBinding() has the method to get relation model:
site->dataBinding()->relationModel().
Last edit: 12 years 1 week ago by Developer Machines.

Please Log in or Create an account to join the conversation.

More
12 years 1 week ago #3 by
Can i use the relation model with a QStringListModel? How can i set the foreign key with this model?

Please Log in or Create an account to join the conversation.

  • 's Avatar Topic Author
12 years 1 week ago #4 by Developer Machines
I think not. This model contains only one column. No place to put the foreign key in it.
I'd suggest QStandardItemModel instead of QStringListModel.

Please Log in or Create an account to join the conversation.

More
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.128 seconds

Developer Newsletter

Join our Developer Machines newsletter to get informed on all the latest releases of the commercial components for Qt.C++, Delphi FireMonkey, updates and general knowledges.

Quick Support

Should you need any additional information about our products or licensing, please contact us at the following email addresses:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

Get in Touch

If you would like to purchase our products or services, but don’t know how to do it the right way, please feel free to contact us:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.( any questions related to our products or services )
  • This email address is being protected from spambots. You need JavaScript enabled to view it.( questions related to licensing )