[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] FW: cascadeSubWindows oversized
From:       David Boddie <david () boddie ! org ! uk>
Date:       2011-05-23 23:31:19
Message-ID: 201105240131.19747.david () boddie ! org ! uk
[Download RAW message or body]

On Monday 23 May 2011, Pietro Moras wrote:
> > Can you describe more accurately what you want to see?
> > David
>
> Simply that all "cascaded" child windows be within the Upper Left – Lower
> Right corners of the host MDI Window, with no scroll bar on. - P.M.

I think you will need to write a function to do this, using the QMdiArea's
subWindowList() method to get the subwindows.

There are lots of constraints you could apply to the way windows are
positioned and resized. This cascade() method might do something similar to
what you want, but it's difficult to get the details right without more
information:

class MdiArea(QMdiArea):

    def cascade(self):
    
        if len(self.subWindowList()) < 2:
            return
        
        windows = []
        for window in self.subWindowList():
            windows.append((window.width(), window.height(), window))
        
        windows.sort()
        
        x = 0
        y = 0
        endX = self.width() - min(windows[-1][0], self.width())
        endY = self.height() - min(windows[-1][1], self.height())
        
        for i in range(len(windows)):
        
            x = i * endX/(len(windows) - 1)
            y = i * endY/(len(windows) - 1)
            
            width, height, window = windows[i]
            window.move(x, y)
            window.resize(min(width, self.width() - x),
                          min(height, self.height() - y))
            window.raise_()

David
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic