Forum
Sign Up
× DataGrid for Qt.C++

Column with checkboxes ignores ItemIsUserCheckable

11 years 2 months ago - 11 years 2 months ago #1 by Pascal
Hi,

When I set ItemFlags to 'Qt::ItemIsSelectable | Qt::ItemIsEnabled' in my model, alle fields are read only except for the checkboxes. A user can still check and uncheck the checkboxes even though Qt::ItemIsUserCheckable has not been set.

The only way to work around this is to disable the column with the checkboxes. Is this working as expected or am I missing something ?

With flags implemented like below checkboxes can be checked/unchecked by the user:

Qt::ItemFlags EnterpriseTableModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags theFlags;
if (index.isValid())
theFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;

return theFlags;
}

This is how I work around the issue:

Qt::ItemFlags EnterpriseTableModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags theFlags;
if (index.isValid())
if (index.column() == isCustomer || index.column() == isBilling)
theFlags = Qt::ItemIsSelectable;
else
theFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;

return theFlags;
}

Sure this cannot be the way to ensure a user cannot check the checkboxes if I did not specify the ItemIsUserCheckable.

Thx
Pascal.

Edit:
I also tried
column = (Qtitan::GridTableColumn*)view->getColumnByModelColumn(EnterpriseTableModel::isBilling);
if (column) column->editorRepository()->setEditorActivationPolicy(Qtitan::NoPolicy);

No change - still able to check and uncheck the checkbox...
Last edit: 11 years 2 months ago by Pascal.

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.114 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 )