Results 1 to 9 of 9

Thread: QtoolBar like movable feature for a widget inside Central Widget

  1. #1
    Join Date
    Mar 2009
    Location
    delhi India
    Posts
    56
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default QtoolBar like movable feature for a widget inside Central Widget

    Hi ,
    My requirement is that i need movable widget(toolbar like ) inside central widget of QMainwindow .
    It should have the ability to be moved atleast to the left most vertical side and right most vertical side of Central widget.

    Attached is the image to get better view of the above requirement.

    I tried following approaches.

    1.Create Dockwidget and add this Dockwidget to layout that is set to central widget.
    But with this approch it dosen't give the look like toolBar as Dockwidget has its own titleBar which i cant get rid of it.

    2.Add the toolbar widget with other widgets to the layout that is set to central widget.
    But with this i cant move the toolbar widget added to the layout.

    3.Create second QMainwindow which can be added to the central widget of the Outer QMainwindow.
    This is the Hack but it solves my purpose.But i dont know how dangerous it would be to maintain in future.
    Is it a good idea of having Qmainwindow inside another Qmainwindow ?

    Please help on this.Any help would be appreciated.

    Thanks.
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QtoolBar like movable feature for a widget inside Central Widget

    Since I can't guess the purpose of what you are doing, the only thing that comes to my mind is:

    1. void setFloatable ( bool floatable ) for the toolbar of your MainWindow
    2. or use QMdiArea if that helps anything

  3. #3
    Join Date
    Mar 2009
    Location
    delhi India
    Posts
    56
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QtoolBar like movable feature for a widget inside Central Widget

    My central widget is already set as MDIArea. As shown in the image i want to have toobars within the central widget apart from the Qtoolbars of QMainwindow which are anyways set to floatable.

  4. #4
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QtoolBar like movable feature for a widget inside Central Widget

    So just create a QToolBar and add to your MDIArea.

  5. #5
    Join Date
    Mar 2009
    Location
    delhi India
    Posts
    56
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QtoolBar like movable feature for a widget inside Central Widget

    Well there isn't any method to add the toobar to MDIArea like addToolbar() function of QMainwindow.......

  6. #6
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QtoolBar like movable feature for a widget inside Central Widget

    There is addWidget though...

  7. #7
    Join Date
    Mar 2009
    Location
    delhi India
    Posts
    56
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QtoolBar like movable feature for a widget inside Central Widget

    i couldn't find the method addwidget so i used addsubwindow .That doesn't solve the purpose As it doesn't give the feel like its toolbar around the QMDIarea rather looks like window within MDIarea.

  8. #8
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QtoolBar like movable feature for a widget inside Central Widget

    Have you tried setting different WindowFlags?

    Anyway if you are already satisfied by using QMainWindow inside your QMdiArea, then it is a perfectly fine solution from my perspective.

  9. #9
    Join Date
    Mar 2009
    Location
    delhi India
    Posts
    56
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QtoolBar like movable feature for a widget inside Central Widget

    Yes i did .
    Please understand that i dont want it to be moved inside the qmdiarea.
    But rather it should have the same behavior as the toobars have for the Qmainwindow i.e it should be movable as top level widget or get fixed into the area colored in gray outside central widget as shown in the figure .


    Added after 7 minutes:


    I am able to implement by creating second QMainWindow (in the form of a regular widget) as the central widget of our MainWindow, and the MDI area as the central widget of the second QMainWindow.
    This way i can add the tool bar to the second main window and it works fine .

    But is it good approch to have QMainwindow as central widget of another QMainwindow. ?
    ITs sure is a hack and m not sure how dangerous it would be to maintain my application in future .
    Last edited by vaibhav; 28th June 2011 at 15:57.

Similar Threads

  1. QToolBar in Win Mobile is not movable?
    By feverzsj in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 26th May 2011, 09:47
  2. Qt Designer About central widget in Qt Designer
    By lrjdragon in forum Qt Tools
    Replies: 2
    Last Post: 3rd April 2010, 17:11
  3. QDockWidgets without central widget
    By JoeMerchant in forum Qt Programming
    Replies: 17
    Last Post: 8th August 2007, 15:52
  4. user resizable and movable QLabel widget
    By hvengel in forum Qt Programming
    Replies: 8
    Last Post: 12th April 2007, 01:01
  5. Central Widget of QMainWindow
    By sumsin in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2006, 19:32

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.