PDA

View Full Version : how coult this happen with the QTableView Column insert?



xiongxiongchuan
13th December 2010, 04:07
i have a slot function on insert a column with the qtableview,and the colde are bleow,i use the libqxt csvmodel function;:

void PFDataGrid::insertColumn(int columnNumber)
{
QxtCsvModel *csvModel=(QxtCsvModel*)(this->model());

csvModel->insertColumn(columnNumber);



}

but when i insert a column ,there is always will insert a column at the end ,can't be edit ,and the first column did't have column number ,can anyone help my ,i will be appreciate it5599

ChrisW67
13th December 2010, 05:58
What value does columnNumber have? Does insertColumn() return true or false?

xiongxiongchuan
13th December 2010, 06:13
void PFDataGrid::insertColumn(int columnNumber)
{
QxtCsvModel *csvModel=(QxtCsvModel*)(this->model());

bool success=csvModel->insertColumn(columnNumber);



}

it returns true;and i use qDebug()<<"column count:"<<columnCount();the columns' count did add

ChrisW67
13th December 2010, 06:17
What value does columnNumber not columnCount() have? Clearly the columnCount is increasing but you are claiming the new column is not where you think it should be.

Please put [code] tags around your code. It is one of the # tools on the tool bar.

xiongxiongchuan
13th December 2010, 06:41
after i call the insertColumn(int columnNumber) function ,it will add a column at the end of the tableview ,and it can't be edit ,but also it will insert a column before the place i inserted,and the column did't have a column header,the header is blank

ChrisW67
13th December 2010, 07:14
This is a libqxt bug that you should report. The following code shows the problem:


#include <QtGui>
#include <QDebug>
#include <QxtCsvModel>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QxtCsvModel m("test.csv");
QTableView v;
v.setModel(&m);
v.show();
qDebug() << "Before:" << m.columnCount();
m.insertColumn(2);
qDebug() << "After: " << m.columnCount();

return app.exec();
}
#include "main.moc"



TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT += sql
CONFIG += qxt
QXT += core

# Input
SOURCES += main.cpp


test.csv:


0,1,2,3,4,5
0,1,2,3,4,5
0,1,2,3,4,5
0,1,2,3,4,5


Output:


Before: 6
After: 7

but 8 columns are visible in the QTableView after the insertColumns() call.

xiongxiongchuan
13th December 2010, 07:32
ok ,i will report this bug to the LibQxt team