-
Bug
-
Resolution: Done
-
P1: Critical
-
4.6.0
-
None
-
d560894ad085ac8c6266fd1af66139db950f473f
Steps to recreate bug:
1. Compile source code (main.cpp, mytable.h, and mytable.cpp) and start the executable. (Note: I'm using Qt 4.6.0-beta1)
2. Click left mouse button on row #3.
3. Press the F1 key to change the column span of row #3.
4. Click left mouse button on row #4.
5. BUG HAPPENS HERE!!! Press the F1 key to change the column span of row #4. This action erroneously changes the column span of row #2 as well, when it should have been left intact.
main.cpp
#include <QtGui/QtGui> #include "mytable.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); MyTable table(5,5); table.show(); return app.exec(); }
mytable.h
#include <QTableWidget> #include <QKeyEvent> class MyTable : public QTableWidget { public: MyTable(int nRows, int nCols); ~MyTable(); protected: void keyPressEvent(QKeyEvent *e); void span(); };
mytable.cpp
#include "mytable.h" MyTable::MyTable(int nRows, int nCols) : QTableWidget(nRows, nCols) { for (int i=0; i<nRows; i++) setSpan(i, 0, 1, nCols); } MyTable::~MyTable() { } void MyTable::keyPressEvent(QKeyEvent *e) { switch(e->key()) { case Qt::Key_F1: span(); break; } QTableWidget::keyPressEvent(e); } //Change column span on current row void MyTable::span() { int row = currentRow(); if (columnSpan(row,0) > 1) setSpan(row, 0, 1, 1); else setSpan(row, 0, 1, columnCount()); }
File: span.pro
TEMPLATE = app
CONFIG += debug qt thread warn_on
HEADERS = mytable.h
SOURCES = main.cpp \
mytable.cpp