Forum
Sign Up
× DataGrid for Qt.C++

limit input size in a cell

10 years 5 months ago #1 by corrado valeri
limit input size in a cell was created by corrado valeri
I'm using the grid with a database table model.
That table has only one column, varchar(6).
Although, while in editing mode, the cell allow more than six chars.
I need to limit the input size to 6 chars.
Attachments:

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

  • corrado valeri
  • corrado valeri's Avatar Topic Author
10 years 5 months ago #2 by Piotr
Replied by Piotr on topic limit input size in a cell
Hi
myModel->select();
QSqlRecord record = myModel->record();
Qtitan::GridTableColumn* column = (Qtitan::GridTableColumn*)myView->getColumnByModelColumn(MyModelClass::MyFieldIndex);
column->setEditorType(Qtitan::StringEditorType);
Qtitan::GridStringEditorRepository* stringEditor = (Qtitan::GridStringEditorRepository*)column->editorRepository();
stringEditor->setMaxLength(record.field(MyModelClass::MyFieldIndex).length());
or
stringEditor->setMaxLength(6);

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

More
10 years 5 months ago #3 by corrado valeri
Replied by corrado valeri on topic limit input size in a cell
It works like a charm :woohoo:
thanks:)

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

  • corrado valeri
  • corrado valeri's Avatar Topic Author
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.127 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 )