How to hide/show all rows?(QTablewidget)
-
@Engelard
It is always like this. Some widgets has some limitaions like for example private member to which there is no access without inheritens. In your case if you have such a problem it would be better to try to know QTableView and how works Model-View-Controlle.
There is plenty articles but the best is Qt help documentation.
Go to qt help and write in the search line: Model. next choose "Model/View Tutorial" -
@mrjj said in How to hide/show all rows?(QTablewidget):
and set model to TableView.
told u i can't set it because it's private)
Correct answer from Slawomir_Piernikowski , but will do so next time. Good lesson that was, every time when will create some huge/important widget - will do that only through manual creation of additional class with inheritance. No fast creation by hands with Designer anymore.
-
@Engelard
"set model to TableView" -> TableVIEW allows setModel :)
You are using the Widget version. which dont allow it.- No fast creation by hands with Designer anymore.
It has nothing to do with Designer. :)
TableWidget is simply slow with that many items and your method of hiding rows
You can insert a TableView in designer too.So its not about using Designer or not.
You can even use designer with custom classes too.
So even if you decide you need a custom class. There is nothing stopping you for using
Designer for some of the forms and then insert classes from code also.So it was more that the class used could not fulfill the requirements of 100K rows and show hide them. :)
And yes, that came around as it was fast and easy to use TableWidget. and its meant to
be easy to use. However, ease of use comes with a price in this case. -
@Engelard
Do not be disappointed. All widgets are only classes and you use them to create objects.
So it is only about object orientated programming. You have to get to know methods in classes and how to use them. But it takes some time.......but after you once write your soft it will be easier to use Model view control in your other project and then it will not take so much time. -
@mrjj said in How to hide/show all rows?(QTablewidget):
"set model to TableView" -> TableVIEW allows setModel :)
To much tables on this week, did'nt see exactly what you wrote) I Will try it.
UPDATE.
Read about tableView. There is so much to remake, replaced my tabWid with View, about 200 errors got, will take a day to remake whole app)) Or maybe more.
QTableView (and other Model/View widgets) is preferable for displaying a significant amount of data.
Well, did'nt know that when i started my app)
-
@Engelard
well that 200 errors is mostly about same stuff i assume.
But yeah, switching to View can be a bit involving later.Btw, you can try
ui->tableWidget->setUpdatesEnabled(false);
for loop with hiderow
ui->tableWidget->setUpdatesEnabled(true);
and see if that speed it up.
But changing to View version will make you more happy in the long run :) -
@mrjj said in How to hide/show all rows?(QTablewidget):
Btw, you can try
ui->tableWidget->setUpdatesEnabled(false);
for loop with hiderow
ui->tableWidget->setUpdatesEnabled(true);
and see if that speed it up.Will not help here - QHeaderView::setSectionHidden() doesn't care for such things and this is simply not meant to hide more than a few rows.
-
@mrjj said in How to hide/show all rows?(QTablewidget):
TableWidget is simply slow with that many items and your method of hiding rows
Why then TableWidget exist? Why they dont just left only View type, what can do tableWidget what can't View?
@mrjj said in How to hide/show all rows?(QTablewidget):
You can even use designer with custom classes too.
How. In my test program i created tableView in designer, how should i create new class for it? I rly can't get it, how it might be created from ui and my custom class simultaneously.
-
@Engelard
Hi
It exists for use cases with just a few hundred items and
is meant as a convenient class. ( it is a View with private model)- how it might be created from ui and my custom class simultaneously.
You can use a feature of Creator called promotion.
http://doc.qt.io/qt-5/designer-using-custom-widgets.html
Think of it as runtime replace. You place say a normal Widget on the form.
and then promote it to your widget subclass. Then when run, its your class
instead of the default one.
- how it might be created from ui and my custom class simultaneously.
-
@Christian-Ehrlicher
Ah, i though HideRow was something else :)
So treeWidget->setUniformRowHeights(true);
will not speed anything up either i assume. -
@mrjj said in How to hide/show all rows?(QTablewidget):
You can use a feature of Creator called promotion.
Hey nice feature. The only thing i don't like, is this message EVERY time i compile my project(brow.h is my mainWindow, main class if you wish):
And every time clicking yes yes yes...
-
Then close the ui_brow.h - since it is generated it will be created on every compile.