October 4, 2011

TaxiRobin TaxiRobin
Lab Rat
2 posts

Same view ‘lay out’ for 2 QTableViews

 

Hi,

At the moment, I have 2 tables. 1 table (name it fileTableView) containts a couple of columns and rows containing data. The second table (call it selectionTableView) has the selected data of the first table (fileTableView).

Now the two tables are aligned horizontal. First you have the fileTableView and beneath that, you have the selectionTableView. Both table views show the exact same columns. For example a column “File Name”. When you now change the geometries of the column File Name, for example the width of the column (by dragging the mouse), the same column File Name in the selectionTableView must also change it’s geometries. So that I get exactly two of the same table views but with one table containing the selected data from the first table.

Now, I’ve tried a couple of things, like for example using a signal that get’s emitted when changing the header widths: QHeaderView::sectionResized(), but this signal just doesn’t get emitted!

I’ve connected it with the following code:

  1. QObject::connect(m_fileTableView->horizontalHeader(),SIGNAL(sectionResized(int,int,int)),m_selectionTableView,SLOT(onSectionResized(int,int,int)));

The onSectionResized is defined as a public slot with the following code:

  1. QHeaderView* selectionHeader = m_selectionTableView->horizontalHeader();
  2.   if(selectionHeader)
  3.    return selectionHeader->resizeSection(index, newSize);
  4.   else
  5.    return ;

While debugging I’ve found out that the signal doesn’t get emitted for the simple reason that the slot onSectionResized never gets called…

So what happens now is that the data in bot tables get’s its updates but the columns width’s in both tables aren’t ‘linked’.

Does anyone has a clue why my signal doesn’t work or is there another method?

Greetings,
Robin

 Signature 

—They Call Him Machete!

2 replies

October 4, 2011

Gerolf Gerolf
Robot Herder
3286 posts

Do you get some statements on the command line /debugger output window for the connect statement? Perhaps, there is a problem.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

October 4, 2011

TaxiRobin TaxiRobin
Lab Rat
2 posts

No, just checked. I’ve got no warnings or special statements from the debugger output.

 Signature 

—They Call Him Machete!

 
  ‹‹ Image Rendering with QGraphics Framework      QNetworkReply emits error signal twice when ContentNotFoundError occures when event loop is started in error slot ››

You must log in to post a reply. Not a member yet? Register here!