PDA

View Full Version : How to remove headers from QTableView.



rajeshs
27th March 2008, 07:17
Hi All,

I am having QTableView, For this view i am using QStandardItemModel My Code is like this,


QTableView *m_pTimeTableView;
QStandardItemModel *m_pTableModel ;

m_pTableModel = new QStandardItemModel(0,5,this);

m_pTableModel->setColumnCount(5);

m_pTableModel->insertRow(0);
m_pTableModel->setData(m_pTableModel->index(0, 0), 160);
m_pTableModel->setData(m_pTableModel->index(0, 1), 123);
m_pTableModel->setData(m_pTableModel->index(0, 2), "XYZ");
m_pTableModel->setData(m_pTableModel->index(0, 3), "XYZ");
m_pTableModel->setData(m_pTableModel->index(0, 4), "XYZ");

m_pTimeTableView->setModel(m_pTableModel);

If i do this I am getting headers in both horizantal and vertical .. and i am getting one more extra column at last .

I want to remove Headers and extra columns in the end. How to do this?

aamer4yu
27th March 2008, 07:30
i guess u can do something like verticalHeader()->hide() ???

rajeshs
27th March 2008, 07:31
I got solution for removing headers Here : Remove Headers (http://www.qtcentre.org/forum/f-newbie-4/t-removing-vertical-header-from-qstandarditemmodel-11630.html/?highlight=QTableView)

How to remove Last extra Column ? and I want to remove Only horizontal Grid ,

I want Vertical Grid to be shown even if there is no data in the Table . how to do this ?

yogeshm02
27th March 2008, 07:34
Create rows as done in docs for QStandardItemModel and see the results then.

rajeshs
27th March 2008, 07:40
I created rows , still i am getting grids,

If i hide grid using showgrid false. Its removing both horizantal and vertical grid lines , i want to remove only horizontal grid lines ?

yogeshm02
27th March 2008, 08:03
I created rows , still i am getting grids,

If i hide grid using showgrid false. Its removing both horizantal and vertical grid lines , i want to remove only horizontal grid lines ?

My reply was regarding extra column problem.

rajeshs
27th March 2008, 08:30
Thank you . please help me how to remove only horizantal grid lines.

HaaZzZ
18th November 2011, 20:00
I think this can help with the lines. It did for me.

http://qt.onyou.ch/2010/07/08/hide-vertical-grid-lines-in-qtableview/

gg.