Results 1 to 7 of 7

Thread: QMainWindow (ForceTabbedDocks)

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QMainWindow (ForceTabbedDocks)

    I have 4 dockWidgets in my app and I want them to be "forced tabbed Docks" when they are docked in the main window to begin with . I did not declare any mainWidget in my main window ( i am not sure if it is ok ), I want my user to have the option to move the dock windows around but once the user dock it it should be a tabbed Docks mode.

    code below at constructor ( this class inherits QMainwindow)
    Qt Code:
    1. setDockOptions(QMainWindow::AnimatedDocks|
    2. QMainWindow::AllowTabbedDocks|
    3. QMainWindow::ForceTabbedDocks);
    4. //DockWidget No 1.
    5. QDockWidget *dock = new QDockWidget(QObject::tr("Sensor 1 - 12"), this);
    6. dock->setAllowedAreas( Qt::RightDockWidgetArea);
    7. ptrTrendPlotter1 = new TrendPlotter(dock,TrendPlotter::sensor1to12);
    8.  
    9. dock->setWidget(ptrTrendPlotter1);
    10. addDockWidget(Qt::RightDockWidgetArea, dock);
    11.  
    12. //DockWidget No 2.
    13. dock = new QDockWidget(QObject::tr("Sensor 13 - 24"), this);
    14. dock->setAllowedAreas( Qt::RightDockWidgetArea);
    15. ptrTrendPlotter2 = new TrendPlotter(dock,TrendPlotter::sensor13to24);
    16.  
    17. dock->setWidget(ptrTrendPlotter2);
    18. addDockWidget(Qt::RightDockWidgetArea, dock);
    19.  
    20. //DockWidget No 3.
    21. dock = new QDockWidget(QObject::tr("Sensor 25 - 36"), this);
    22. dock->setAllowedAreas( Qt::RightDockWidgetArea);
    23. ptrTrendPlotter3 = new TrendPlotter(dock,TrendPlotter::sensor25to36);
    24.  
    25. dock->setWidget(ptrTrendPlotter3);
    26. addDockWidget(Qt::RightDockWidgetArea, dock);
    27.  
    28. //DockWidget No 4
    29. dock = new QDockWidget(QObject::tr("Sensor 37 - 48"), this);
    30. dock->setAllowedAreas(Qt::RightDockWidgetArea);
    31. ptrTrendPlotter4 = new TrendPlotter(dock,TrendPlotter::sensor37to48);
    32.  
    33. dock->setWidget(ptrTrendPlotter4);
    34. addDockWidget(Qt::RightDockWidgetArea, dock);
    To copy to clipboard, switch view to plain text mode 

    please help,

    baray98

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow (ForceTabbedDocks)

    Connect a slot to the QDockWidget::topLevelChanged signal.
    When the parameter is false, then the widget is docked and youi can changed its features to features() & (~QDockWidget:ockWidgetFloatable).

    Regards

  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMainWindow (ForceTabbedDocks)

    thanks for the quick reply but my first problem is that in my code i have attached them all on leftDockArea hoping that the four widget will be forcetabbedDocks by my mainWindow but it did'nt happen the output is four dockwidget evenly displayed in my mainWindow.

    please help,

    baray98

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow (ForceTabbedDocks)

    Aa, ok. I see now.
    Do you set fixed sizes/maximum sizez for the docks and/or widgets vontained by them?
    F. e. what does the TrendPlotter constructor?

    Regards

  5. #5
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMainWindow (ForceTabbedDocks)

    i did not set fixed sizes/maximum sizez for the docks and/or widgets vontained by them.

    should i set them to some sizes so that forcetabbedDocks feature will kick in?

    baray98

  6. #6
    Join Date
    May 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow (ForceTabbedDocks)

    I have similar problem with dock widgets. AFAIK this is added as a bug, but it'll be solved in some future release :/...

  7. #7
    Join Date
    Jul 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMainWindow (ForceTabbedDocks)

    Hi

    I run into the same problem.
    Luckily there is a solution
    ...
    ...
    dock->setWidget(ptrTrendPlotter4);
    addDockWidget(Qt::RightDockWidgetArea, dock);

    // First give all <dock>s as dock1,2,3,4
    // Then
    tabifyDockWidget( dock1, dock2 );
    tabifyDockWidget( dock2, dock3 );
    tabifyDockWidget( dock3, dock4 );

    // A cruid method but works

    Regards
    Pritpal Bedi
    Pritpal Bedi
    a student of software analysis and design

Similar Threads

  1. QMainWindow modal from non-qt window?
    By hickscorp in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 09:10
  2. How do I add a QGridlayout in a QMainwindow?
    By Teuniz in forum Qt Programming
    Replies: 4
    Last Post: 14th February 2007, 10:18
  3. QMainWindow not receiving QResizeEvent
    By brcain in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2006, 06:11
  4. Dynamically Loading a QMainWindow?
    By natron in forum Newbie
    Replies: 10
    Last Post: 21st July 2006, 01:15
  5. Replies: 18
    Last Post: 22nd February 2006, 20:51

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.