CustomEditor Example
#ifndef WINDOW_H
#define WINDOW_H
#include <QTimer>
#include <DevMachines/QtitanGrid>
#include "DemoMainWindow.h"
class Window : public DemoMainWindow
{
Q_OBJECT
public:
Window();
QWidget* createSettingsWidget();
private Q_SLOTS:
void autoWidthStateChanged(int state);
void fastScrollChanged(int state);
void dottedLineChanged(int state);
void selectGridLineStyles(int index);
void zoomEnabledChanged(int state);
void zoomIndicatorChanged(int state);
void cellButtonAutoRaiseEnabled(int state);
void frozenRowsEnabled(int state);
void transparentBackgroundEnabled(int state);
void rowSizingEnabled(int);
void contextMenu(ContextMenuEventArgs* args);
void cellButtonClicked(CellButtonClickEventArgs* args);
void printPreview();
void editorModifying(GridEditor* editor);
void editorValidating(EditorValidationEventArgs* args);
void zoomValueChanged(int value);
void setShadeColor(const QColor& color) override;
private:
Qtitan::Grid* m_grid;
};
class CustomEditWidget : public QLineEdit
{
public:
CustomEditWidget(QWidget* parent);
protected:
void mouseDoubleClickEvent(QMouseEvent*) override;
};
class CustomEditorRepository : public GridEditorRepository
{
public:
CustomEditorRepository();
GridEditor* createEditor() override;
private:
};
class CustomEditor : public GridEditorBase
{
Q_OBJECT
public:
explicit CustomEditor();
~CustomEditor() override;
QWidget* getCellWidget() override;
void repositoryUpdated() override;
void paintEvent(QPainter& painter, const GridEditorStyleOption& option) override;
void mouseOverEvent(QEnterEvent* e) override;
void mouseOutEvent() override;
void focusInEvent(QFocusEvent* e) override;
void updateContext(const QVariant& value) override;
void createEditModeContext() override;
void destroyEditModeContext() override;
void setValueToWidget(const QVariant& value) override;
private:
CustomEditWidget* m_customWidget;
private Q_SLOTS:
void textEdited(const QString& text);
};
#endif