PDA

View Full Version : questions about qscrollarea in qsplitter



mcarter
4th April 2014, 19:18
sorry this is rather long . . .

My main app uses a QSplitter to separate data views and allows the user to resize those views using the splitter handle, normal stuff. There is an optional panel at the top display that can hold many items in q QScrollArea. These items consist of a QFrame with a vertical layout containing a square QGraphicsView (gv) positioned above a QButton. This panel is currently a fixed size. Users have now asked for the panel to be resizable, and that is where I am having a little problem.

I have attached a sample app (10257). The app builds to a 'square' binary. This takes two optional arguments, number of views to create (defaults to 2) and square option (0=smallest dimension or 1=height only, default to 0), eg. ./square 6 1.

Basic explanation on what I am trying to achieve. I what to control the size of the item's gv widget so that it does not get too big, so I set a min size of 50 and max size of 200. I want this to also limit the adjustable height of the QScrollArea when changed by the splitter handler. I need to keep a square shape of the gv widget. I was able to find some software on the net that helps control the square shape of the gv. After a few tweaks, I was able to get it to work in my app (and also added option to control how the square shape is controlled, either (0) by the smallest of height/width or (1) by height only). However, I want all the views to have the same size gv widget when resized.

(1) So, first issue is the adjustable size of the QScrollArea. The min height seems to work out properly, it is the max height that I am having trouble with. I set the QScrollArea max height to the max of the max heights of all the items, and currently I set the max height of an item to a fixed number. So that sort of works, but currently leaves a lot of extra space. I am not sure how/where to compute the height of the framed item at runtime to get a more accurate number, which I think needs to be based on max height of gv, max height of button (probably based on font), and margins within the frame and layout.

(2) The other issue is having same size gv widget for each item. If you run the sample app with 6 views, this will show button labels with various sizes. Without 2nd argument (square option) or using 0, you will see gv's at different sizes (based on size of buttons in the frame) [10259]. I thought it would be easier to have same size squares if I based square shape on height. So, if you use 2nd argument as 1, then they maintain same size square based on height, but the items' parent frames do not resize to hold new size of child, as gv width changes [10258]. How do I force the QFrame to resize based on gv child resizing? Or is it better to somehow store a height across all items and set them all to this overal height, by some means?