Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, January 2007
QMainWindow and saving positions of child widgets Qt : Qt 3.3.6


Message 1 in thread

Hi All,

I am working on an open source project called KWebTest.
I have lots of dockwidgets in a QMainWindow

I want the position of all the dock windows (ie child widgets) to be remebered 
automatically upon application shutdown and want them to be restored when the 
application starts again.


Can someone please tell me as to how it can be made possible?

Regards
Manish

--
 [ signature omitted ] 

Message 2 in thread

Hi,

quoted from the Qt 3.3 documentation
(http://doc.trolltech.com/3.3/qmainwindow.html#details) :

 To save the layout and positions of all the dock windows do this:

    QFile file( filename );
    if ( file.open( IO_WriteOnly ) ) {
        QTextStream stream( &file );
        stream << *mainWindow;
        file.close();
    }


To restore the dock window positions and sizes (normally when the
application is next started), do following:

    QFile file( filename );
    if ( file.open( IO_ReadOnly ) ) {
        QTextStream stream( &file );
        stream >> *mainWindow;
        file.close();
    }


I think creating a QTextStream for a QString
(http://doc.trolltech.com/3.3/qtextstream.html#QTextStream-3) and then
saving that QString using QSettings should work, but I don't have a Qt
3.3 installed to test it.


Regards,
Ralf

Manish Chakravarty schrieb:
> Hi All,
> 
> I am working on an open source project called KWebTest.
> I have lots of dockwidgets in a QMainWindow
> 
> I want the position of all the dock windows (ie child widgets) to be remebered 
> automatically upon application shutdown and want them to be restored when the 
> application starts again.
> 
> 
> Can someone please tell me as to how it can be made possible?
> 
> Regards
> Manish
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 

-- 
 [ signature omitted ] 

Message 3 in thread

Manish Chakravarty skrev:
> Hi All,
> 
> I am working on an open source project called KWebTest.
> I have lots of dockwidgets in a QMainWindow
> 
> I want the position of all the dock windows (ie child widgets) to be remebered 
> automatically upon application shutdown and want them to be restored when the 
> application starts again.

Call saveGeometry() on each of the dock widgets and on your main window, 
and store each of them in QSettings. On loading, use restoreGeometry() 
with that QByteArray.

You have to give your dock widgets object names for this to work.

Bo.

-- 
 [ signature omitted ]