View scaling in PyQt?

I have a simple tree-like application that displays a QTreeView inside a QMainWindow. . I want to give the user the ability to change the level of increase in content (most likely, use a spinbox), but without changing the main font size for the text.

Is there a way to do this without changing my entire application to QGraphicsScene ? The application simply shows a good old tree with text, no graphics, or anything other than the desire to change the magnification of the view; therefore, I think the transition to the graphic scene would be redundant.

Or am I mistaken and switching to the graphic scene is the only easy way to do this?

Please note that the shortened version of the application is in the code overview. It contains SSCCE, but it is slightly longer to publish here.

On the site we discuss how to place widgets on the stage , wrote trolltech (highlighted by me):

I myself and several other Trolls spent some time exploring this topic [how to embed a widget in QGraphicsScene]. Its not trivial; most solutions for embedding widgets in a scene end with several serious flaws. Thats also why Qt doesn't have any ready made solution to this.

Widgets cannot be scaled or rotated, but graphic elements can.

This suggests that I cannot perform the operations that I want to use for my QWidget simple way. That is, perhaps I need to add it to the scene, which I tried to avoid. If this is the answer, then I will accept it and start a new question if I am stuck with this.

Note. I just found this question , which is largely duplicated and has no (accepted) answer.

Associated Content

+1
source share
1 answer

As suggested by the documents mentioned in trolltech in the original question, there is no built-in zoom method.

If the goal is to avoid using QGraphicsViews, the easiest way to separate the font size on the screen from the font size saved or printed is basically to have two fonts. One of them, which will be displayed on the screen, you can call "zoom", and the other - save / print and name it "font size".

I got this idea from qtcentre (in the post I added to the original post too):

http://www.qtcentre.org/threads/62745-Zoom-a-view

0
source

All Articles