Results 1 to 8 of 8

Thread: Sizing Issues

  1. #1
    Join Date
    Feb 2006
    Location
    Raleigh, NC
    Posts
    16
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Question Sizing Issues

    I'm continually running into the problem of my child widgets appearing all scrunched together in a little box instead of taking up what I would imagine is the actual screen space. I'm not sure why such small size parameter are being passed down. I don't want to set minimum/maximum sizes as this needs to be adapted to different screens.

    My immediate problem is setting a splitterinside a tab. It takes up maybe a quarter of the width. The children of the splitter are thus in a small space instead of taking up the whole tab. I think there is something fundamental to Qt I am missing here. If someone could give me a hint with how to procede it would be greatly appreciated.

    I'm using PyQt but its all the similar, here is how I'm specifying the splitter size:
    splitter.setGeometry(QRect(0, 25, self.frameSize().width(), self.frameSize().height()))

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Sizing Issues

    Yes, you are missing something This something is called "layouts" Take a look at the QLayout class and its descendants, Johan's tutorial and official Qt tutorial for details.

  3. #3
    Join Date
    Feb 2006
    Location
    Raleigh, NC
    Posts
    16
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Sizing Issues

    I'm familiar wtih layouts. If I'm using a splitter though is it necessary for me to put it in a layout as it will be the only item directly inside the tab. I'm using layouts to organize all the child widgets of the splitter though.

    class DrugProfile(QWidget):
    def __init__(self, parent):
    QWidget.__init__(self, parent)
    splitter = QSplitter(Qt.Vertical, self, "header")
    splitter.setOpaqueResize(TRUE)
    splitter.setGeometry(QRect(0, 25, self.frameSize().width(), self.frameSize().height()))
    head = Header(splitter) #top child
    table = Tables(splitter) #bottom child
    splitter.show()

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sizing Issues

    Maybe you should use sizeHint() instead of frameSize()? Widget sizes aren't valid until the widget is shown for the first time.

  5. #5
    Join Date
    Feb 2006
    Location
    Raleigh, NC
    Posts
    16
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Sizing Issues

    It came back with the same results.

    When I comment out the code of the children it gets even smaller. So the size of the splitter is being determined by its child classes, its widest childset. I think I'll have to investigate that further. I'll have to figure out how to get the children to take up the whole space.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Sizing Issues

    You should put that splitter into a layout too. And the parent should not be a QWidget. Or you can derive your class directly from QSplitter (it'll be even better this way).

    Something like:

    Qt Code:
    1. class DrugProfile(QSplitter):
    2. def __init__(self, parent):
    3. QSplitter.__init__(Qt.Vertical, self, parent)
    4. setOpaqueResize(TRUE)
    5. head = Header(self) #top child
    6. table = Tables(self) #bottom child
    7. show()
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to wysota for this useful post:

    Solarity (16th March 2006)

  8. #7
    Join Date
    Feb 2006
    Location
    Raleigh, NC
    Posts
    16
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Sizing Issues

    Ok I'll give that a try too. I have a vague memory of having done that but it really makes more sense anyway.

  9. #8
    Join Date
    Feb 2006
    Location
    Raleigh, NC
    Posts
    16
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Sizing Issues

    It worked! Thanks!! I'll post if I have another related question but this looks like I am majorly closer to what I want. Its always a simple solution .

Similar Threads

  1. Popup notification window issues on Mac
    By alexandersv in forum Qt Programming
    Replies: 2
    Last Post: 20th April 2012, 11:15
  2. Custom Scroll Widget Sizing Problem
    By sepehr in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2008, 11:42
  3. QSqlDatabase connectivity issues
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 16th July 2008, 12:58
  4. Speed, transparency, and drop issues with QGraphicsView
    By jefferai in forum Qt Programming
    Replies: 16
    Last Post: 30th June 2007, 16:14
  5. MySql plugin driver issues
    By stevey in forum Installation and Deployment
    Replies: 11
    Last Post: 20th September 2006, 13:45

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.