Reputation: 207
As QTableView has public function setRowHidden() and setColumnHidden(), but if person A performs hide operation, how can person B get to know the changes? If there is a signal available that gives an idea about the geometry changes in QTableView ?
Thanks ahead.
Upvotes: 2
Views: 1025
Reputation: 207
With the happiest mood, I finally found the solution to observe the hide/show behavior of a row/column in tableView. The method still goes-back to the signal/slot mechanism. Just because of strange terminology in Qt's system, some concepts are really not very straight-forward and confusing.
QTableView *tableView = new QTableView;
tableView->setRowHidden(0, true);
This will make a tableView's the 0st row hide. This operation actually just makes the row's section resizes. The result of this is the size of the section is ZERO, and signal sectionResized() emitted.
Upvotes: 2
Reputation: 717
No, signal is not emitted an doc doesn't say anything about it, but you can make it easily by yourself.
Just create subclass of QTableView
and override setRowHidden
and setColumnHidden
methods, call original methods and add your signal emissions inside. Something like that:
MyTableView.h
#include <QTableView>
class MyTableView : public QTableView
{
Q_OBJECT
public:
MyTableView(QWidget *parent = Q_NULLPTR);
~MyTableView();
void setColumnHidden(int column, bool hide);
void setRowHidden(int row, bool hide);
signals:
void columnHidden(int column, bool hide);
void rowHidden(int row, bool hide);
};
MyTableView.cpp
#include "mytableview.h"
MyTableView::MyTableView(QWidget *parent) : QTableView(parent)
{
}
MyTableView::~MyTableView()
{
}
void MyTableView::setRowHidden(int row, bool hide)
{
QTableView::setRowHidden(row, hide);
emit rowHidden(row, hide);
}
void MyTableView::setColumnHidden(int column, bool hide)
{
QTableView::setColumnHidden(column, hide);
emit columnHidden(column, hide);
}
Now you can call your overloaded methods just like the original ones.
Upvotes: 1