Results 1 to 8 of 8

Thread: Own defined Dockareas

  1. #1
    Join Date
    Feb 2007
    Posts
    28
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Own defined Dockareas

    QMainWindow defines four areas where widgets can be docked.
    Is it possible to define my own dockareas?
    It should be a component like QFrame that i can place anywere and dock widgets to it.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Own defined Dockareas

    Quote Originally Posted by jobrandt View Post
    QMainWindow defines four areas where widgets can be docked.
    Is it possible to define my own dockareas?
    It should be a component like QFrame that i can place anywere and dock widgets to it.
    No, I'm afraid this is not possible without rewriting the whole main window framework. Define "anywhere"? How would other widgets in the main window layout behave?
    J-P Nurmi

  3. #3
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Own defined Dockareas

    Qt4.3 having 8 dock areas(included corner), but you can dock more than 8.
    like you can dock multiple widget in left side, in left1 & left2.

  4. #4
    Join Date
    Feb 2007
    Posts
    28
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Own defined Dockareas

    With left1 & left2 etc. i could manage the layout i wanted. I could fix the position of windows that should not be moved.
    But there is now another problem: How can set the size and position of docked windows?
    This problem was discussed several time in this forum. But there was no solution that really satisfy.
    From Delphi i know the element TPanel. It has the property DockSite. If it is set to true you can dock other TPanel to it if the other TPanel has the property DragKind=dkDock.
    With TPanel i can do what ever i can do with QFrame.
    But I think there is no (easy) way to implement something like TPanel.

  5. #5
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Own defined Dockareas

    you can set the size and position of dockwidget using
    DockWidgetArea and sizeHint.
    I set the size and position of docked windows by using DockWidgetArea and sizeHint.
    but sometime you have to change the sizeHint of other widget to fix size of first widget.

  6. #6
    Join Date
    Feb 2007
    Posts
    28
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Post Re: Own defined Dockareas

    How are you using sizeHint?
    Here is some code that displays 2 QDockWidget. Docker1 should be displayed at position 100,100 and should have the size 100x200. This works fine.
    But i can't set the width of Docker2 to 100.
    Qt Code:
    1. DockTest::DockTest(QWidget *parent, Qt::WFlags flags)
    2. : QMainWindow(parent, flags)
    3. {
    4. ui.setupUi(this);
    5.  
    6. QDockWidget *Docker1 = new QDockWidget(this);
    7. Docker1->setObjectName("Docker1");
    8.  
    9. QFrame *frame1 = new QFrame(Docker1);
    10. QVBoxLayout *la1 = new QVBoxLayout(Docker1);
    11. QListWidget *lw1 = new QListWidget(Docker1);
    12. QPushButton *pb1 = new QPushButton(Docker1);
    13.  
    14. frame1->setLayout(la1);
    15. la1->addWidget(lw1);
    16. la1->addWidget(pb1);
    17. Docker1->setWidget(frame1);
    18.  
    19. addDockWidget(Qt::RightDockWidgetArea,Docker1);
    20. Docker1->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
    21. Docker1->setFloating(true);
    22. Docker1->setGeometry(100,100,100,200);
    23.  
    24. // --------------------------------------------
    25.  
    26. QDockWidget *Docker2 = new QDockWidget(this);
    27. Docker2->setObjectName("Docker2");
    28.  
    29. QFrame *frame2 = new QFrame(this);
    30. QVBoxLayout *la2 = new QVBoxLayout(Docker2);
    31. QListWidget *lw2 = new QListWidget(Docker2);
    32. QPushButton *pb2 = new QPushButton(Docker2);
    33.  
    34. frame2->setLayout(la2);
    35. la2->addWidget(lw2);
    36. la2->addWidget(pb2);
    37. Docker2->setWidget(frame2);
    38.  
    39. addDockWidget(Qt::LeftDockWidgetArea,Docker2);
    40. Docker2->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
    41. Docker2->setFloating(false);
    42. // Docker2 should be displayed with a width of 100
    43. Docker2->setGeometry(10,10,100,100); // does not work
    44. Docker2->setMinimumWidth(100); // does not work
    45.  
    46. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Own defined Dockareas

    Hi,
    here is the code for you.
    Qt Code:
    1. DockerDockWidget *Docker2 = new DockerDockWidget(this);
    2. ...
    3. class DockerDockWidget : public QDockWidget
    4. {
    5. public:
    6. DockerDockWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
    7. virtual QSize sizeHint() const;
    8. virtual QSize minimumSizeHint() const;
    9. private:
    10. QSize szHint, minSzHint;
    11. };
    12.  
    13. DockerDockWidget::DockerDockWidget(QWidget *parent, Qt::WindowFlags flags)
    14. :QDockWidget(parent, flags)
    15. {
    16. szHint = QSize(100, -1); // this sets initial or default size
    17. minSzHint = QSize(75, 75); // this sets minimum size
    18. }
    19. QSize DockerDockWidget::sizeHint() const
    20. {
    21. return szHint;
    22. }
    23. QSize DockerDockWidget::minimumSizeHint() const
    24. {
    25. return minSzHint;
    26. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 16th July 2007 at 12:47. Reason: changed [html] to [code]

  8. The following user says thank you to rajesh for this useful post:

    jobrandt (18th July 2007)

  9. #8
    Join Date
    Feb 2007
    Posts
    28
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Own defined Dockareas

    This works good for Qt 4.2.3 . It does not work for Qt 4.3.0. Trolltech told me that there is still a task (tasktracker #168726).

Similar Threads

  1. How to suppress user defined events in processEvents()
    By Artschi in forum Qt Programming
    Replies: 5
    Last Post: 5th July 2007, 10:17
  2. Replies: 4
    Last Post: 26th June 2007, 19:19
  3. Signal defined in "a.h" can not emit in "b.cpp"
    By Shawn in forum Qt Programming
    Replies: 9
    Last Post: 21st May 2007, 16:55
  4. Linking problems with multiply defined symbols
    By JimBrown in forum Qt Programming
    Replies: 5
    Last Post: 2nd March 2007, 16:48
  5. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23

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.