//--------------------------------------------------
// main.cpp contents
//--------------------------------------------------

#include "main.h"
int paints_cnt = 0;	// Global variable - paintEvent calls counter

void QTableWidgetEx::paintEvent(QPaintEvent* e)
	{
	++paints_cnt;
	QTableWidget::paintEvent(e);
	}

void MainWindow::on_call_update()
	{
	table_widget_ex->update();
	};

void MainWindow::on_check_paint_cnt()
	{
	statusBar->showMessage("paints_cnt = " + QString::number(paints_cnt));
	};

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
	{
	resize(400, 300);

	menuBar = new QMenuBar(this);
	setMenuBar(menuBar);

	table_widget_ex = new QTableWidgetEx(this);
	table_widget_ex->setUpdatesEnabled(true);
	setCentralWidget(table_widget_ex);

	statusBar = new QStatusBar(this);
	setStatusBar(statusBar);

	auto call_update = new QAction("call_update", this);
	connect(call_update, SIGNAL(triggered()), this, SLOT(on_call_update()));
	menuBar->addAction(call_update);

	auto check_paint_cnt = new QAction("check_paint_cnt", this);
	connect(check_paint_cnt, SIGNAL(triggered()), this, SLOT(on_check_paint_cnt()));
	menuBar->addAction(check_paint_cnt);
	};

int main(int argc, char *argv[])
	{
	QApplication a(argc, argv);
	MainWindow w;
	w.show();

	return a.exec();
	};
