To reproduce use the following example:

Steps to reproduce:

1.) Push Change (the sub window grows)
2.) Push Change (the sub window size doesn't change)
3.) Push Resize (the sub window size changes)

(It works when the layout has the size constraint: SizeConstraint.SetFixedSize, 
but it's not resizable!)


import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QCleanlooksStyle;
import com.trolltech.qt.gui.QFormLayout;
import com.trolltech.qt.gui.QGridLayout;
import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QLineEdit;
import com.trolltech.qt.gui.QMainWindow;
import com.trolltech.qt.gui.QMdiArea;
import com.trolltech.qt.gui.QMdiSubWindow;
import com.trolltech.qt.gui.QPushButton;
import com.trolltech.qt.gui.QWidget;
import com.trolltech.qt.gui.QLayout.SizeConstraint;

public class QDynamicLayoutMain extends QMainWindow
{
        QLineEdit leUsr = new QLineEdit();
        QLineEdit lePwd = new QLineEdit();
        
        QLineEdit leNewPwd = new QLineEdit();
        
        QLabel lblUsr = new QLabel("Username");
        QLabel lblPwd = new QLabel("Password");
        QLabel lblNewPwd = new QLabel("Confirm");
        
        QPushButton butLogin = new QPushButton("Login");
        QPushButton butChange = new QPushButton("Change");
        QPushButton butResize = new QPushButton("Resize");
        
        QMdiArea desktop = new QMdiArea();
        QMdiSubWindow frameLogin = new QMdiSubWindow();
        
        QMainWindow widgetLogin = new QMainWindow();

        public static void main(String[] pArgs) 
    {
        QApplication.initialize(pArgs);
        QApplication.setStyle(new QCleanlooksStyle());
        
        QDynamicLayoutMain main = new QDynamicLayoutMain();
        main.show();
        
        QApplication.exec();
    }
        
        public QDynamicLayoutMain()
        {
                QWidget wgCentral = new QWidget();
                
                QFormLayout layLogin = new QFormLayout();
        
//this line of code resizes the sub window as expected, but it's fixed size :(  
        
//              
frameLogin.layout().setSizeConstraint(SizeConstraint.SetFixedSize);
                
                layLogin.addRow(lblUsr, leUsr);
                layLogin.addRow(lblPwd, lePwd);
                layLogin.addRow(lblNewPwd, leNewPwd);
                layLogin.addRow(butChange, butLogin);
                layLogin.addWidget(butResize);
                
                wgCentral.setLayout(layLogin);
                
                widgetLogin.setCentralWidget(wgCentral);
                
                frameLogin.setWidget(widgetLogin);
                
                desktop.addSubWindow(frameLogin);
                
                setCentralWidget(desktop);
                
                lblNewPwd.setVisible(false);
                leNewPwd.setVisible(false);
                
                //configuration
                
                butChange.clicked.connect(this, "change(boolean)");
                butResize.clicked.connect(this, "resize(boolean)");
                
                resize(500, 500);
        }
        
        public void change(boolean checked)
        {
                lblNewPwd.setVisible(!lblNewPwd.isVisible());
                leNewPwd.setVisible(!leNewPwd.isVisible());

                frameLogin.adjustSize();
        }
        
        public void resize(boolean checked)
        {
                frameLogin.adjustSize();
        }

}       // QDynamicLayoutMain

-------- Original-Nachricht --------
> Datum: Thu, 12 Mar 2009 13:54:46 +0100
> Von: [email protected]
> An: [email protected]
> Betreff: [Qt-jambi-interest] Widget/Layout adjustment

> I wrote some custom layouts (BorderLayout, HVSequenceLayout) for Jambi.
> The layouts work as expected but i have a problem when the layout size
> changes:
> 
> I have a login dialog for my application with username, password and a
> Login Button.
> (implemented with a QMainWindow as widget of a SubWindow in an MdiArea)
> 
> The same dialog will be used for password change.
> 
> The user can change it's password during login, so it's possible to switch
> the pwd-dialog mode. In that case, the invisible fields will be
> visible/invisible and the dialog should resize.
> -> And the dynamic resize is the problem!
> 
> I tried to call adjustSize but that didn't do anything. 
> 
> I found some ?problems? with layouting events:
> 
> EVENT Show
> EVENT ShowToParent
> EVENT LayoutRequest
> EVENT Paint
> EVENT Paint
> EVENT LayoutRequest
> EVENT LayoutRequest
> 
> 
> The LayoutRequest event came to late, because the dialog is visible and
> then it receives the LayoutRequest. Through this LayoutRequest the layout
> will calculate the preferred size, but "too late", because the dialog doesn't
> change its size.
> 
> I tried a lot of things, maybe anyone out there can help me solving my
> problem or can explain the behaviour?
> -- 
> Nur bis 16.03.! DSL-Komplettanschluss inkl. WLAN-Modem für nur 
> 17,95 ¿/mtl. + 1 Monat gratis!*
> http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
> _______________________________________________
> Qt-jambi-interest mailing list
> [email protected]
> http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

-- 
Nur bis 16.03.! DSL-Komplettanschluss inkl. WLAN-Modem für nur 
17,95 ¿/mtl. + 1 Monat gratis!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to