1

I have a simple to do tree application that displays a QTreeView inside of a QMainWindow. I want to give the user the ability to change the magnification level of the content (using a spinbox most likely), but without actually changing the underlying font size of the text.

Is there a way to do this without changing my whole app to a QGraphicsScene? The app is just showing a good-old fashioned tree with text, no graphics or anything fancy other than wanting to change the magnification of the view; hence, I am thinking that switching to a graphics scene would be overkill.

Or, am I wrong, and switching to a graphics scene is the only simple way to do it?

Note a trimmed down version of the app is at Code Review. It contains a SSCCE, but is a bit long to post here.

In a site discussing how to put widgets on a scene, trolltech wrote (emphasis added):

I myself and several other Trolls’ve spent some time researching this topic [how to embed a widget in a QGraphicsScene]. It’s not trivial; most solutions to embedding widgets into a scene end up with several serious drawbacks. That’s also why Qt doesn’t have any off-the-shelf solution to this.

Widgets cannot be scaled or rotated, but graphics items can.

This suggests I cannot perform, in a simple way, the operations I want to on my QWidget by itself. That is, perhaps I need to add it to a scene, which is what I was trying to avoid. If that is the answer, then I'll accept it and start a new question if I get stuck doing that.

Note I just found this question, which is pretty much a duplicate, and does not have an (accepted) answer.

Related content

Community
  • 1
  • 1
eric
  • 7,142
  • 12
  • 72
  • 138

1 Answers1

0

As suggested by the docs quoted from trolltech in the original question, there is no built-in method to zoom on a view.

If the goal is to avoid the use of QGraphicsViews, the simplest way to separate the size of the font on the screen, versus the size of the font saved or printed, is to basically have two fonts. One to be displayed on the screen you can call 'zoom', versus the other to be saved/printed and call that 'font size'.

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

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

eric
  • 7,142
  • 12
  • 72
  • 138