-1

I'm not sure either it's some kind of bug\glitch or I'm doing something wrong. I have some hidden rows in the table and on click I want them to appear but result you can see on the picture below. before click after click

This effect occurs only when slider is scrolled till the end. Glitch disappears if I change focus to another window or when I scroll table up until it goes out of view.

Here is my code:

connect(tableView_, SIGNAL(clicked(const QModelIndex &)), this,
    SLOT(onTableClicked(const QModelIndex &)));

for(int i = 0; i < table_->rowCount(); i++)
{
    if(i%table_->typesNumber())
        tableView_->hideRow(i);
}

...

void DumpsComparisonWindow::onTableClicked(const QModelIndex& index)
{
   ...
   tableView_->showRow(index.row() + i);
   ...
}

UPDATE: to make it possible to test I have created cut version of my project, you can find it here: https://gitlab.com/JuicyPussy/qtableview_glitch

JuicyKitty
  • 318
  • 1
  • 16

1 Answers1

1

After showing or hiding any rows make the model notify about the change in the layout to all views. You do that by calling layoutChanged.

void DumpsComparisonWindow::onTableClicked(const QModelIndex& index)
{
   ...
   tableView_->showRow(index.row() + i);
   ...
   table_->layoutChanged(); //add this
}
JuicyKitty
  • 318
  • 1
  • 16
Pablo Yaggi
  • 1,061
  • 5
  • 14
  • layoutChanged() is a signal of QAbstractItemModel, but the answer helped in some way – JuicyKitty Jul 24 '20 at 16:03
  • 1
    yes, it is a signal, and you are allowed to emit it, and when you do the glitch goes away. Remember it is not necessary to use 'emit' to emit a signal, you can just call it like I show you. Cheers ! – Pablo Yaggi Jul 24 '20 at 16:06