I forgot to mention that this is for WM5.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of George H.
Locktish
Sent: Wednesday, April 09, 2008 9:59 AM
To: [email protected]
Subject: Re: [Qtce-preview-feedback] QTableView andsetStretchLastSectionproblem
Thank you for your help. Below is a sample application I have created that
reproduces this issue. I have noticed that if I switch the order of calling
setModel() on the QTableView and the setStretchLastSection(), then the headers
are displayed properly. This issue appears to be a combination of the order in
which we call the setModel() and setStretchLastSection() methods and our custom
TableModel.
#include <QAbstractTableModel>
#include <QApplication>
#include <QDirModel>
#include <QHeaderView>
#include <QTableView>
class TestModel : public QAbstractTableModel
{
public:
TestModel(QObject *_parent = 0);
int rowCount(const QModelIndex &_parent = QModelIndex()) const;
int columnCount(const QModelIndex &_parent = QModelIndex()) const;
QVariant data(const QModelIndex &_index, int _role) const;
QVariant headerData(
int _section,
Qt::Orientation _orientation,
int _role = Qt::DisplayRole) const;
private:
static const int NUMBER_ROWS = 1;
static const int NUMBER_COLS = 2;
};
TestModel::TestModel(QObject *_parent) :
QAbstractTableModel(_parent)
{
}
int TestModel::rowCount(const QModelIndex &_parent) const
{
if (!_parent.isValid())
return NUMBER_ROWS;
return 0;
}
int TestModel::columnCount(const QModelIndex&) const
{
return NUMBER_COLS;
}
QVariant TestModel::data(
const QModelIndex &_index,
int _role) const
{
if (!_index.isValid())
return QVariant();
if (_role != Qt::DisplayRole)
return QVariant();
if (_index.row() < 0 || _index.row() >= NUMBER_ROWS)
return QVariant();
if (_index.column() < 0 || _index.column() >= NUMBER_COLS)
return QVariant();
if (_index.column() == 0)
{
return "P1";
}
else
return "V1";
}
QVariant TestModel::headerData(
int _section,
Qt::Orientation _orientation,
int _role) const
{
if (_role != Qt::DisplayRole)
return QVariant();
if (_orientation != Qt::Horizontal)
return QVariant();
if (_section == 0)
{
return QString("Property");
}
else
{
return QString("Value");
}
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTableView* view = new QTableView;
view->horizontalHeader()->setStretchLastSection(true);
view->setModel(new TestModel(view));
view->show();
return a.exec();
}
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jörg Bornemann
Sent: Wednesday, April 09, 2008 6:51 AM
To: [email protected]
Subject: Re: [Qtce-preview-feedback] QTableView and setStretchLastSectionproblem
George H. Locktish wrote:
> When I call setStretchLastSection() on the horizontal header for my
> QTableView, the last column's header view text is not displayed when the
> GUI is displayed. If I remove the call to setStretchLastSection() on
> the horizontal header, then the text for the last column is displayed.
> The other columns of the header view display without issue.
I just tried to reproduce your problem with the current Qt/WinCE 4.4.0
RC1 on Windows Mobile 5 with the following little program:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTableView* tv = new QTableView;
tv->setModel(new QDirModel(tv));
tv->horizontalHeader()->setStretchLastSection(true);
tv->show();
return a.exec();
}
All headers are displayed properly.
Which Qt/WinCE version and platform are you using?
Could you please provide a code sample which shows the problem?
Best Regards,
Jörg
_______________________________________________
Qtce-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qtce-preview-feedback
_______________________________________________
Qtce-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qtce-preview-feedback
_______________________________________________
Qtce-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qtce-preview-feedback