1 Attachment(s)
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.
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
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.
Re: QtoolBar like movable feature for a widget inside Central Widget
So just create a QToolBar and add to your MDIArea.
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.......
Re: QtoolBar like movable feature for a widget inside Central Widget
There is addWidget though...
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.
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.
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 .