How can I always show the horizontalHeader, even if the qtableview is empty?
Currently when the tableview is empty, the horizontalheader will be automatically hidden. But I want it always shown. Is there anyway to do that?
Re: How can I always show the horizontalHeader, even if the qtableview is empty?
did you try:
pMyTable->horizontalHeader()->setVisible(true); ?
Re: How can I always show the horizontalHeader, even if the qtableview is empty?
yeah, but it has no effect.
Re: How can I always show the horizontalHeader, even if the qtableview is empty?
Can you show your code?
Is the table generated in code, or designer?
Re: How can I always show the horizontalHeader, even if the qtableview is empty?
Sorry, I cannot show my code.
The table is generated by code, and it's totally following the model/view architecture. Basically it looks lke this:
class A: public QAbstractTableModel{...};
class B: pulbic QSortFilterProxyModel{...};
class C: public QTableView{...};
A a;
B b;
C c;
b.setModel(&a);
c.setModel(&b);
Here c is the table. Everything just works fine, except that the horizontalHeader of c automatically disappears when I hide all columns in c. I just want the horizontalHeader always shown.
Re: How can I always show the horizontalHeader, even if the qtableview is empty?
Quote:
when I hide all columns in c
This is not the same as:
Quote:
Currently when the tableview is empty
Hidden is not same as empty.
You probably will have to manually call showSection() on the hidden columns,when you hide you columns.