John Smith
2nd March 2009, 12:22
I made a class which inherits QTableWidget and has resizeEvent().
#include <QDialog>
#include <QBoxLayout>
#include <QApplication>
#include <QBoxLayout>
#include <QTableWidget>
#include <QHeaderView>
#include <QResizeEvent>
#include <QDebug>
class TableBase : public QTableWidget
{
public:
TableBase(QWidget *parent = 0) : QTableWidget(10, 10, parent) {}
protected:
void resizeEvent(QResizeEvent *event) {/*...*/}
};
class A : public QDialog
{
public:
A();
private:
TableBase *table;
QVBoxLayout *layout;
};
A::A()
{
table = new TableBase(this);
layout = new QVBoxLayout(this);
layout->addWidget(table);
table->setSpan(0,0,5,1);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
A a;
a.show();
return app.exec();
}
When I executed the program, some of rows and columns were hidden because of small dialog box. So I resized the window, but I found following problems.
First, the horizontal header and the vertical header weren't redrawn.
Second, the program crashed with following assertion failure.
ASSERT: "i >= 0 && i < size()" in file ../../include/QtCore/../../src/corelib/tools/qbitarray.h, line 118
When I resized the window slightly and then resized one section, the headers were redrawn. Doing it repeatedly was not cause the program to crash.
Qt version is 4.5-rc1
#include <QDialog>
#include <QBoxLayout>
#include <QApplication>
#include <QBoxLayout>
#include <QTableWidget>
#include <QHeaderView>
#include <QResizeEvent>
#include <QDebug>
class TableBase : public QTableWidget
{
public:
TableBase(QWidget *parent = 0) : QTableWidget(10, 10, parent) {}
protected:
void resizeEvent(QResizeEvent *event) {/*...*/}
};
class A : public QDialog
{
public:
A();
private:
TableBase *table;
QVBoxLayout *layout;
};
A::A()
{
table = new TableBase(this);
layout = new QVBoxLayout(this);
layout->addWidget(table);
table->setSpan(0,0,5,1);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
A a;
a.show();
return app.exec();
}
When I executed the program, some of rows and columns were hidden because of small dialog box. So I resized the window, but I found following problems.
First, the horizontal header and the vertical header weren't redrawn.
Second, the program crashed with following assertion failure.
ASSERT: "i >= 0 && i < size()" in file ../../include/QtCore/../../src/corelib/tools/qbitarray.h, line 118
When I resized the window slightly and then resized one section, the headers were redrawn. Doing it repeatedly was not cause the program to crash.
Qt version is 4.5-rc1