[Qt-interest] QDockWidget size

Oszkar Ambrus oszkar.ambrus at deri.org
Tue Dec 8 23:43:17 CET 2009


On 08/12/09 23:35, Josiah Bryan wrote:
> 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.

Thanks a lot! For now I put a vertical layout on the widget, and it 
gives an initial size to the dock widget.

-- 
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]




More information about the Qt-interest-old mailing list