Results 1 to 5 of 5

Thread: resize a docked QDockWidget programmatically

  1. #1
    Join Date
    Jan 2011
    Posts
    23
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default resize a docked QDockWidget programmatically

    Hi,

    is there any way to resize a docked QDockWidget programmatically ? I have three dock windows one on the left side, one on the right side and one at the bottom.
    I'd like to make the bottom window smaller in height since is contains only log information

    Qt Code:
    1. dock = new QDockWidget(tr("bottomDock"), this);
    2. dock->setAllowedAreas(Qt::AllDockWidgetAreas);
    3. QPlainTextEdit *logEdit = new QPlainTextEdit(dock);
    4. dock->setWidget(logEdit);
    5. dock->resize(200,200); //not working
    6. addDockWidget(Qt::BottomDockWidgetArea, dock);
    To copy to clipboard, switch view to plain text mode 

    I have tried calling resize() on the logEdit but no luck.
    The only way to make it work I found is to use setMaximumHeight on logEdit but I don't like that solution.

    Anybody knows more appropriate solution to this problem ?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: resize a docked QDockWidget programmatically

    The dock widgets size is managed by the QMainWindow layout - so forcing the widget to a max height is probably your only simple way to do it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2011
    Posts
    23
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: resize a docked QDockWidget programmatically

    OK thanks. if there is no simple solution can anyone recommend more advance solution to this problem ? that I could try

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: resize a docked QDockWidget programmatically

    You could subclass QLayout and set it as your QMainWindow layout.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Aug 2012
    Posts
    4
    Qt products
    Platforms
    Windows

    Default Re: resize a docked QDockWidget programmatically

    I am facing the same problem. I too need to resize a docked QDockWidget programmatically (change it's width on some user action).

    Can I have some sample example code for using layout for QDockWidget (advance solution to this problem) by which you think we may be able to resize the docked QDockWidget programmatically.

    Thanks.

Similar Threads

  1. Floating QDockWidget not re-docked by QMainWindow::restoreState
    By stefanadelbert in forum Qt Programming
    Replies: 14
    Last Post: 20th October 2016, 21:16
  2. how to hide the title bar when a QDockWidget is docked?
    By oscar721 in forum Qt Programming
    Replies: 5
    Last Post: 23rd January 2014, 20:16
  3. Resize a QDockWidget ? (Width)
    By Selven in forum Qt Programming
    Replies: 5
    Last Post: 29th April 2012, 13:54
  4. resize QDockWidget
    By Gh0str1d3r in forum Qt Programming
    Replies: 0
    Last Post: 27th August 2010, 11:18
  5. Replies: 3
    Last Post: 3rd September 2008, 16:41

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.