Thanks for the info. The problem is that for QTreeView this issue is fixed but not for QTableView. I'm using Qt 4.1.2 and for different source code I have different results
#include <QApplication>
#include <QTableView>
#include <QTreeView>
#include <QStandardItemModel>
int main(int argc, char **argv)
{
// Prepend 4 rows into the model
model->insertRows(0, 4);
// Prepend 4 columns into the model
model->insertColumns(0, 4);
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
{
// Return a model index for the given row and column.
// Set the index's data to the specified value
model
->setData
(index,
QVariant("hello\nnextline\nonemoreline"));
}
}
view.setModel(model);
view.show();
return app.exec();
}
#include <QApplication>
#include <QTableView>
#include <QTreeView>
#include <QStandardItemModel>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QTreeView view;
QStandardItemModel *model = new QStandardItemModel;
// Prepend 4 rows into the model
model->insertRows(0, 4);
// Prepend 4 columns into the model
model->insertColumns(0, 4);
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
{
// Return a model index for the given row and column.
QModelIndex index = model->index(row, col);
// Set the index's data to the specified value
model->setData(index, QVariant("hello\nnextline\nonemoreline"));
}
}
view.setModel(model);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Here the result:
QTreeView_example.jpg
Now I'm changing only one line: QTreeView is replaced with QTableView
#include <QApplication>
#include <QTableView>
#include <QTreeView>
#include <QStandardItemModel>
int main(int argc, char **argv)
{
// Prepend 4 rows into the model
model->insertRows(0, 4);
// Prepend 4 columns into the model
model->insertColumns(0, 4);
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
{
// Return a model index for the given row and column.
// Set the index's data to the specified value
model
->setData
(index,
QVariant("hello\nnextline\nonemoreline"));
}
}
view.setModel(model);
view.show();
return app.exec();
}
#include <QApplication>
#include <QTableView>
#include <QTreeView>
#include <QStandardItemModel>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QTableView view;
QStandardItemModel *model = new QStandardItemModel;
// Prepend 4 rows into the model
model->insertRows(0, 4);
// Prepend 4 columns into the model
model->insertColumns(0, 4);
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
{
// Return a model index for the given row and column.
QModelIndex index = model->index(row, col);
// Set the index's data to the specified value
model->setData(index, QVariant("hello\nnextline\nonemoreline"));
}
}
view.setModel(model);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
And now I have the wrong output:
QTableView_example.jpg
Do you think I should send this as a bug to Trolltech?
Bookmarks