Here is a standalone example. let me know if it works for you.
#include <QApplication>
#include <QTableWidget>
{
public:
MyTableWidget
(int r,
int c,
QWidget *parent
= 0) {
}
protected:
int sizeHintForRow(int row) const
{
return 100;
}
};
int main(int argc, char* argv[])
{
MyTableWidget *tbl = new MyTableWidget( 10, 8 );
tbl->setFocusPolicy( Qt::NoFocus );
for ( int r = 0; r < 10; r++)
for ( int c = 0; c < 8; c++ )
tbl->resizeRowsToContents();
tbl->show();
return app.exec();
}
#include <QApplication>
#include <QTableWidget>
class MyTableWidget : public QTableWidget
{
public:
MyTableWidget (int r, int c, QWidget *parent = 0)
: QTableWidget(r,c,parent)
{
}
protected:
int sizeHintForRow(int row) const
{
return 100;
}
};
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
MyTableWidget *tbl = new MyTableWidget( 10, 8 );
tbl->setSelectionMode( QAbstractItemView::NoSelection );
tbl->setEditTriggers(QAbstractItemView::NoEditTriggers);
tbl->setFocusPolicy( Qt::NoFocus );
for ( int r = 0; r < 10; r++)
for ( int c = 0; c < 8; c++ )
tbl->setItem( r, c, new QTableWidgetItem( QString::number(r+1)+" "+QString::number(c+1)) );
tbl->resizeRowsToContents();
tbl->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks