Results 1 to 6 of 6

Thread: DockWidgets problem

  1. #1
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default DockWidgets problem

    Hi!
    I have an application with 3 dock widgets in it's QMainWindow. Dock widgets are only closable and each of them has only one allowed area. They are connected with checkable actions in menu like this:
    Qt Code:
    1. connect(ui.actionProject_Explorer, SIGNAL(toggled(bool)), projectExplorerWidget, SLOT(setVisible(bool)));
    2. connect(projectExplorerWidget, SIGNAL(visibilityChanged(bool)), ui.actionProject_Explorer, SLOT(setChecked(bool)));
    To copy to clipboard, switch view to plain text mode 
    So dock widget can be closed with X button or with unchecking action. There are two problems:
    1. When I change size of a dock widget (with a mouse, during runtime), then close it and show it again, it has an initial size, no the size I set with mouse. How can I force them to remember that?

    2. When I have some of those dock widgets visible and then minimize my app and restore, all dock widgets are always closed, even if they were visible before minimizing :/ How can I keep the state which was before minimizing?

    I have tested my app on Vista and Kubuntu 8.04 and it works same on both platforms.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: DockWidgets problem

    Any ideas?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: DockWidgets problem

    Quote Originally Posted by faldżip View Post
    1. When I change size of a dock widget (with a mouse, during runtime), then close it and show it again, it has an initial size, no the size I set with mouse. How can I force them to remember that?
    You could make the dock widgets members of your class, and also keep variables that store the width and height of each dock widget. Then capture the "closing" or "hiding" of each dock widget and store its size before closing it. Then when it reappears, just resize it with the values you stored in your class.

    Quote Originally Posted by faldżip View Post
    2. When I have some of those dock widgets visible and then minimize my app and restore, all dock widgets are always closed, even if they were visible before minimizing :/ How can I keep the state which was before minimizing?
    Maybe store bools in your class if the dock widgets are visible again changing the state to false when you close them and true when you open them.

    One thing to maybe keep in mind if it's possible is are you destroying the dock widget when you close it or just hiding the dock widget so its the same object when you reshow it? If you are destroying them upon closing them, this would explain why their behavior changes from time to time, because you create a whole new dock widget that has no knowledge of its predecessor.

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: DockWidgets problem

    Quote Originally Posted by ToddAtWSU View Post
    One thing to maybe keep in mind if it's possible is are you destroying the dock widget when you close it or just hiding the dock widget so its the same object when you reshow it? If you are destroying them upon closing them, this would explain why their behavior changes from time to time, because you create a whole new dock widget that has no knowledge of its predecessor.
    As I wrote in first post, I connect toggled(bool) with setVisible(bool) so I think I'm just hiding and showing and it's not destrying it.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: DockWidgets problem

    Have you verified that you are or when you are getting into these slots either by setting a break point or a print statement?

  6. #6
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: DockWidgets problem

    OK, i found solution for problem 2. I have to add to my menu a QDockWidget::toggleViewAction() instead of creating my own actions.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Qt is a trademark of The Qt Company.