[Qt-interest] QDockWidget size

Josiah Bryan jbryan at productiveconcepts.com
Tue Dec 8 22:35:20 CET 2009


Oszkar Ambrus wrote:
> On 08/12/09 22:50, Josiah Bryan wrote:
>> Oszkar Ambrus wrote:
>>> Hi,
>>>
>>> I've browsed the archives and I couldn't find any hints on my question.
>>> I'm using Qt Creator to create a UI with a QMainWindow and I have a 
>>> QDockWidget with some contents.
>>>
>>> The problem is that every time I start the application, the dock 
>>> widget is shrunk down completely, and I have to resize it manually.
>>> I tried by resizing it in the main window constructor, but I just 
>>> don't manage to do it.
>>>
>>> Is there a solution to this?
>>>
>>>   
>> QMainWindow::saveState and restoreState
>
> Well I'd like it to behave that way on the first run when the app is 
> installed. Or should I do that with restoreState a well?
Good question - that one I don't know. I've thought of doing a 
'saveState' to a byte array, saving that byte array to a file, then 
adding that file as a resource to the program.

Then when you go to do a "first run" on a fresh system, check your 
QSettings object to see if your state key exists. If not, then load the 
byte array from the resource and restore state from that.

Just an idea though - I havn't tried it yet myself.
-josiah







More information about the Qt-interest-old mailing list