Results 1 to 1 of 1

Thread: Widget resizing issues

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Widget resizing issues

    This seems to be a basic problem but I can't figure it out. I have a QMainWindow with a QTabWidget. Throughout my application I add different tabs to my main window, these tabs sometimes include large items which don't fit in the current tab space.

    Here are my specific issues:
    1) When adding a tab that requires a minimum amount of space to view all its child widgets, how can I grow my main window to fit this tab properly.
    2) When resizing my main window, I'd like it to not shrink past the minimum size my tab requires, when growing my main window, I'd like my tab to grow with it. This seems like basic functionality but I can't seem to get it to work!

    What I've tried is using a QScrollArea, so that if the main window does shrink too much, scroll bars will appear and my tab widget is still "in tact" (all buttons are readable, etc., but I have to scroll to see everything). This isn't behaving properly though because as I resize my main window, my scroll area sort of "resets" its minimum size to its last size, so if I make it really big (larger than needed), then shrink it, the scrollbars appear right away (as opposed to shrinking my tab until its minimum size and then adding scroll bars when needed). I do set my scroll bar policies to Qt::ScrollBarAsNeeded. I also tried with and without setSizeConstraint(QLayout::SetMinimumSize) on my main layout that my scroll area is inside and I've tried with and without setSizePolicy(QSizePolicy::MinimumExpanding,QSizeP olicy::MinimumExpanding); on the widget that my scroll area "sets". I'm now thinking a scroll area is not the way to go (and I just need to make sure my main window is big enough, but isn't there always a possibility that the computer screen will just be too small to show all the widgets at once?)

    Without the scroll area, everything behaves much better but my custom widget that I am displaying inside my tab doesn't seem to have a minimum any more. You can resize the main window so small that the buttons and combo boxes just overlap on top of eachother and squish together really small. (Resizing larger does make the widget grow as desired)

    I'm now thinking my problem is just that I need to set the minimum size to exact values, but what if I don't know the dimensions? I just want it to fit all its child widgets (which are arranged in layouts).

    What am I missing?

    I did leave out one thing. I put a "resized" signal in my parent widget and connected that to a slot in my custom widget that i am displaying in my tab that resizes my child widget to its allotted space in the parent widget. Without this the second method I tried (without the scroll area) doesn't resize the widget in the tab at all, it just always stays the size its first displayed. I did try everything with and without this slot. Either way the widget shrinks too much when the user shrinks the main window, which I'd just like the user to not be able to shrink past the tab widget's minimum size! (or do allow that but add scroll bars afterwards and ONLY after its shrunken past the minimum, when i tried the scroll bars they were always added when shrinking the window (no matter how large the window was).

    Update: If I do hardcode the minimum size to values that I guessed at, the buttons don't overlap when the window shrinks too much but the widget gets cut off, so you can only see the portion in its top left corner. Why can't I make my main window not shrink past the size needed for its child? Is it because this widget is inside a QTabWidget?
    Last edited by SKolaMunn; 15th September 2011 at 15:50.

Similar Threads

  1. Resizing child widget
    By drmath in forum Qt Programming
    Replies: 4
    Last Post: 16th November 2010, 10:32
  2. Widget is not so smooth when resizing?
    By MorrisLiang in forum Newbie
    Replies: 2
    Last Post: 11th May 2010, 01:44
  3. QDock Widget resizing
    By vajindarladdad in forum Qt Programming
    Replies: 0
    Last Post: 9th December 2008, 10:12
  4. Resizing child Widget
    By Pragya in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2007, 06:58
  5. Widget resizing problem
    By fwohlfert in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2006, 08:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.