Forum
Sign Up
× DataGrid for Qt.C++

Problems with CustomEditType

12 years 5 days ago #1 by
Hi,
i make a custom grideditor like the documentation. In the display mode it works ok, but when i switch to the edit mode i get the exception:

ASSERT: "false" in src\grid\QtnGridTableView.cpp, line 2554

The header file:
#include <QtitanGrid.h>

class GridFormulaEditor : public Qtitan::GridStringEditor
{
Q_OBJECT
public:
GridFormulaEditor();
~GridFormulaEditor();
virtual void paintEvent(QPainter & painter, const GridEditorStyleOption & option);
};

class GridFormulaEditorRepository : public Qtitan::GridEditorRepository
{
public:
GridFormulaEditorRepository();
virtual GridEditor* createEditor();
};

The Source:
GridFormulaEditor::GridFormulaEditor() : Qtitan::GridStringEditor()
{
}

GridFormulaEditor::~GridFormulaEditor()
{
}

void GridFormulaEditor::paintEvent(QPainter & painter, const GridEditorStyleOption & option)
{
QRect rect = option.rect;
rect.adjust(4, 4, -4, -4);
Qtitan::GridStringEditor::paintEvent(painter, option);
}

GridFormulaEditorRepository::GridFormulaEditorRepository()
{
}

GridEditor* GridFormulaEditorRepository::createEditor()
{
return new GridFormulaEditor();
}

and

pColumn->setEditorType(Qtitan::CustomEditType);
pColumn->setEditorRepository(new GridFormulaEditorRepository());

whe i use GridStringEditor instead, the program works.

Could you tell me whats wrong?

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

  • 's Avatar Topic Author
12 years 4 days ago #2 by Developer Machines
This assert means what you have no default value for this editor repository. In your case the best way inherit repository from GridStringEditorRepository.

class GridFormulaEditorRepository : public Qtitan::GridStringEditorRepository
{
}

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

More
12 years 3 days ago #3 by
Replied by on topic Problems with CustomEditType
When i inherit the repository for GridStringEditorRepository it works, but when i a column where in the Qt::ItemFlags ItemIsEditable is not set (ReadOnly) i get the same exception.
How can i solve this?

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

  • 's Avatar Topic Author
12 years 3 days ago #4 by Developer Machines
Please show me the code of the column's editor initialization.

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

More
12 years 1 day ago #5 by
Replied by on topic Problems with CustomEditType
Here is the code:

pColumn->setEditorType(Qtitan::CustomEditType);
pColumn->setEditorRepository(new GridFormulaEditorRepository());

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

  • 's Avatar Topic Author
11 years 11 months ago #6 by
Replied by on topic Problems with CustomEditType
I have solve the problem.

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

  • '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.137 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 )