On Tuesday, 21. Mar 2006 19:28
KShots@warfaresdl.com wrote:
Hello,
The example below works fine for me in the latest snapshot. I suggest
you try the latest snapshot to see if this solves your problem.
#include <QApplication>
#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"));
}
}
view.setModel(model);
view.show();
return app.exec();
}
#include <QApplication>
#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"));
}
}
view.setModel(model);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
>
> Created a model and linked it to a QTreeView. The data() in one of the
> columns contains newline characters.
>
> What I expected to see:
>
> Some rows of the tree having multiple lines, depending on the number
> of newlines / line wraps in the data
>
> What I got instead:
>
> Each row had exactly one line of text, with some rows showing some
> portion of multiple lines of text (looks like it just looks at the
> "middle"
>
> More info:
>
> This is discussed in some more depth (with some examples) at the
> following URL:
>
>
http://www.qtcentre.org/forum/showth...9&goto=newpost
>
> Note that it appears to be working in 4.1.0, and breaks again in 4.1.1
> according to the topic.
>
Best regards,
Sigrid Fjell Nævdal
--
Trolltech AS, Sandakerveien 116, P.O.Box 4332 Nydalen, 0402 Oslo, Norway
Bookmarks