Hi All,
I have made a QTableView with 200 rows and 4 columns.. but the column header are invisible and here is my code snippet.
toolform.cpp
ToolForm
::ToolForm(QDialog *parent, Qt
::WindowFlags f
){
setupUi(this);
setupModel();
setupViews();
init();
}
ToolForm::~ToolForm()
{
}
void ToolForm::init()
{
}
void ToolForm::setupModel()
{
model->setHeaderData(0, Qt::Horizontal, tr("NUMBER"));
model->setHeaderData(1, Qt::Horizontal, tr("DIAMETER"));
model->setHeaderData(2, Qt::Horizontal, tr("LENGTH"));
model->setHeaderData(3, Qt::Horizontal, tr("UNITS"));
}
void ToolForm::setupViews()
{
tooltableView->setModel(model);
tooltableView->setSelectionModel(selectionModel);
}
ToolForm::ToolForm(QDialog *parent, Qt::WindowFlags f)
: QDialog( parent, f)
{
setupUi(this);
setupModel();
setupViews();
init();
}
ToolForm::~ToolForm()
{
}
void ToolForm::init()
{
}
void ToolForm::setupModel()
{
model = new QStandardItemModel(200, 4, this);
model->setHeaderData(0, Qt::Horizontal, tr("NUMBER"));
model->setHeaderData(1, Qt::Horizontal, tr("DIAMETER"));
model->setHeaderData(2, Qt::Horizontal, tr("LENGTH"));
model->setHeaderData(3, Qt::Horizontal, tr("UNITS"));
}
void ToolForm::setupViews()
{
QTableView *tooltableView = new QTableView;
tooltableView->setModel(model);
QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
tooltableView->setSelectionModel(selectionModel);
}
To copy to clipboard, switch view to plain text mode
toolform.h
#ifndef TOOLFORM_H
#define TOOLFORM_H
#include <QVariant>
#include <QDialog>
#include "ui_toolform.h"
class ToolForm
: public QDialog,
private Ui
::ToolForm{
Q_OBJECT
public:
ToolForm
( QDialog* parent
= 0, Qt
::WindowFlags f
= Qt
::FramelessWindowHint);
~ToolForm();
private:
void setupModel();
void setupViews();
void init();
};
#endif // TOOLFORM_H
#ifndef TOOLFORM_H
#define TOOLFORM_H
#include <QVariant>
#include <QDialog>
#include "ui_toolform.h"
class QAbstractItemModel;
class QItemSelectionModel;
class ToolForm : public QDialog, private Ui::ToolForm
{
Q_OBJECT
public:
ToolForm( QDialog* parent = 0, Qt::WindowFlags f = Qt::FramelessWindowHint);
~ToolForm();
private:
void setupModel();
void setupViews();
void init();
QAbstractItemModel *model;
QItemSelectionModel *selectionModel;
};
#endif // TOOLFORM_H
To copy to clipboard, switch view to plain text mode
How to resolve this issue.
Bookmarks