Results 1 to 9 of 9

Thread: Using QDockWidget in a QFrame

  1. #1
    Join Date
    May 2010
    Posts
    41
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Using QDockWidget in a QFrame

    Hi,

    I've noticed that the QDockWidget can only actually be docked within a MainWindow. I'd like to be able to have one which docks only within a QFrame. Is this possible, and why exactly does it have this behaviour?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 268 Times in 268 Posts
    Wiki edits
    20

    Default Re: Using QDockWidget in a QFrame

    A QMainWindow has the docking infrastructure, a QFrame does not.
    So, no you can't use a QDockWidget in the same way in a QFrame as you do in a QMainWindow.

    Why do you want dock widgets in a frame?

  3. #3
    Join Date
    May 2010
    Posts
    41
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Re: Using QDockWidget in a QFrame

    The problem lies in not being able to nest QMainWindows (assuming I'm not wrong about that). What I have is a mainwindow with different perspectives, switched via checkable toolbar buttons. The perspective change only alters everything below the toolbar, essentially loading almost an entire new part of the software. As a result, it's as if each of these perspectives is its own MainWindow, without its own toolbars. But since I can't just place a MainWindow within another, I use a QFrame.

    This problem at hand is actually a bit more complicated, since I want my DockableWidget to reside in another QFrame nested in the one I spoke of above. Essentially, I have something resembling the following:



    Everything below the toolbar is within a QFrame. And the right side of the treeview is actually another QFrame. As you can see, in that frame is where I want the QDockWidget to be.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Using QDockWidget in a QFrame

    You might need to do some clever hack for dock widget drag and drop.. you can extract the widget from QDockWidget and set it as a child of QFrame..
    then on drag event, you can again set the widget as child of QDockWidget.....

    it might not be easy,,, but thats what came to my mind

  5. #5
    Join Date
    May 2010
    Posts
    41
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Re: Using QDockWidget in a QFrame

    Quote Originally Posted by aamer4yu View Post
    You might need to do some clever hack for dock widget drag and drop.. you can extract the widget from QDockWidget and set it as a child of QFrame..
    then on drag event, you can again set the widget as child of QDockWidget.....

    it might not be easy,,, but thats what came to my mind
    Ooohh...I like the idea. I'll give it a shot.

    It still surprises me, though, that the library is like this. Has no one else ever wanted to use a QDockWidget in something nested within their QMainFrame?

  6. #6
    Join Date
    Jun 2010
    Posts
    23
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows Maemo/MeeGo
    Thanked 5 Times in 5 Posts

    Default Re: Using QDockWidget in a QFrame

    Quote Originally Posted by Polnareff View Post
    Ooohh...I like the idea. I'll give it a shot.

    It still surprises me, though, that the library is like this. Has no one else ever wanted to use a QDockWidget in something nested within their QMainFrame?
    Im curious about it! I've tried the same, but i found no "look and feel" solution to put the dockwidget back into the widget or in your case the frame. However, why didnt you nest your mainwindow into a widget and this widget into the mainwindow?

  7. #7
    Join Date
    May 2010
    Posts
    41
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Re: Using QDockWidget in a QFrame

    Can you nest a mainwindow? Cuz as far as I know, each time I try it just creates it as a new dialog. Otherwise I wouldn't have a problem. I guess I'll give it another shot...

  8. #8
    Join Date
    Jun 2010
    Posts
    23
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows Maemo/MeeGo
    Thanked 5 Times in 5 Posts

    Default Re: Using QDockWidget in a QFrame

    I can't try it out atm, but I'm pretty shure. Maybe

    Qt Code:
    1. setWindowFlags(Qt::Widget);
    To copy to clipboard, switch view to plain text mode 
    will help?!
    Last edited by CeeKey; 1st June 2010 at 15:18.

  9. The following user says thank you to CeeKey for this useful post:

    Polnareff (1st June 2010)

  10. #9
    Join Date
    May 2010
    Posts
    41
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Re: Using QDockWidget in a QFrame

    That worked! It was so simple :P Thanks a bunch!

Similar Threads

  1. QFrame inner rectangle
    By Micawber in forum Qt Programming
    Replies: 6
    Last Post: 1st April 2009, 20:40
  2. QFrame V and H Line
    By bunjee in forum Qt Programming
    Replies: 5
    Last Post: 5th September 2008, 19:30
  3. Using css for all QFrame's except one.
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 10th July 2008, 08:05
  4. QFrame size
    By impeteperry in forum Qt Programming
    Replies: 3
    Last Post: 17th August 2007, 12:51
  5. Reg - QFrame
    By suresh in forum Qt Programming
    Replies: 1
    Last Post: 1st November 2006, 04:34

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.