DzCode last edited by DzCode
I have a QFrame as parent and inside it I have some tables.
Inside this frame if CTRL+ or CTRL- key action is performed, the tables should be zoomed in or out (also their headers nad cell size should be changed).
I could not find a proper way to do this. What is your advice to implement a functionality for zooming in tableviews
I also used setfont of qtableviews with the below code.
cells size and cell item fonts changed. However, header font does not change. setfont of it does not work
However, header font does not change. setfont of it does not work
Did you call it on the header? Maybe you set a style sheet on it?
Yes, Now I am doing it inside my custom header view with stylesheet. However, when the point size of the font changed, the names of columns are not fitted to their own area.
For example if the header name is "Measurement". It looks "asure" after zooming. The names should be like in the case of there is no zoom. If there is alide like this "Measure..." also after zoom it should be " Measure...", not "Mea...".
Then you have to resize your header sizes accordingly.
yes but I want to ask something.
Is there any other way to do zooming instead of changing fonts?
No, not that I'm aware of.
I am asking this, because Icons and pixmaps in the decoration role does not change with the change of the font. image sizes also should change with zooming
You could maybe subclass HeaderView and overwrite paintSection
do your own image and text scaling.
Do you also need the actual cells to scale this way ?
You could add your own delegate and scale images and text too.
I am resizing the images inside a proxymodel now.
However, there is one thing left to solve my all problems.
I am using checkstaterole of my model to make some columns checkable. There is problem about resizing them. I dont want to replace them with QCheckBox. I created checboxes with the help of the Qt::ItemIsUserCheckable flag. How can I resize them?
Ok that sounds good too.
I have never tried to style the "checkable" but I think you can control it with a delegate and
Update: nope, it wont care if given bigger or smaller rect.
bascially it boils down to
style->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &opt, painter, widget);
I did it via stylesheet of QtableView::indicator.
Thanks both of you for your support
Good work. So even using stylesheets it zooms fast enough ?
@mrjj I didnt test it with chrono since I didnt have a time to, but for user perspective, there is no problem if you have less table