Results 1 to 3 of 3

Thread: Technique for creating a main window that can be programatically resized and animated

  1. #1
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Technique for creating a main window that can be programatically resized and animated

    I've been working on an app that has some special behavior.

    At the top level it is a frameless widget that can be shown just as a "toolbar" that is docked to the top of the users monitor when the user enters a search word in the toolbar it expands downwards to show results. The program can also "autohide" itself and be re-shown when the user mouses over it, for the autohiding I render the content widget as a pixmap, hide the real content and show a qlabel with the pixmap this way I was able to prevent the content from getting distorted and specify alignment as it animates out. In the different states the program also has a different minimum size.

    From the very beginning I have had problems with the program not redrawing itself properly as it was being dynamically resized and had to implement an ugly little hack function I call refresh that invalidates layouts, calls updategeometry and repaint. In one situation i actually move the program 1px and then move it back (otherwise it just refused to redraw itself with the updated geometry)

    Now I am porting my program to mac, and my "refresh" function is causing flicker
    Does anybody have any advice on how I should have implemented this top level expanding / compacting widget?

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Technique for creating a main window that can be programatically resized and anim

    From your description it looks like that you messed up something in your code, most of this things should work out of the box.
    For animation you have QPropertyAnimation.

  3. #3
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Technique for creating a main window that can be programatically resized and anim

    I am using QPropertyAnimation.

    It is not out of the box, top level widgets in Qt do not automatically re-size to fit their contents

    I am programmatically resizing the top level widget when the child widget that contains the toolbar and results pane shows and hides the results pane. There is also a notification area which when it shows notifications expands the top level widget and when the notifications are hidden and the top level widget is resized back to its original size the, When this happens the searchwidget updates itself to take over the space of the notification widget but does not take into account the now smaller size of the top level widget.

    My structure is like this

    topFramelessWidget
    - NotificationWidget
    - SearchWidget
    ------- ToolbarWidget
    ------- ResultsPaneWidget

    I am not sure maybe the things i do in my refresh function are necessary on windows everything appears smoothly but on mac its like you can see when it repaints it shows blank and then draws the content it looks really awful when it blinks like that

Similar Threads

  1. Error creating a animated menu
    By CassioTC in forum Newbie
    Replies: 3
    Last Post: 26th March 2011, 00:42
  2. Replies: 1
    Last Post: 19th July 2010, 11:43
  3. Creating a Main Window Application
    By gt.beta2 in forum Qt Tools
    Replies: 13
    Last Post: 24th February 2009, 19:45
  4. Replies: 11
    Last Post: 11th August 2008, 09:14
  5. QMdiSubWindow problem with resized window
    By estanisgeyer in forum Qt Programming
    Replies: 2
    Last Post: 7th January 2008, 14:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.