Is there any ways to change the outstyle of the window close button?
-
I found that some projects set the Window flag so that we can define a single button to replace the default window close button.So is there any other easilier ways to change the outstyle of the close button?
-
I found that some projects set the Window flag so that we can define a single button to replace the default window close button.So is there any other easilier ways to change the outstyle of the close button?
Create a window without the default window decoration (e.g.
Qt::FramelessWindowHint) and then make your own buttons to close, maxi- or minimize your window. -
Create a window without the default window decoration (e.g.
Qt::FramelessWindowHint) and then make your own buttons to close, maxi- or minimize your window.@Pl45m4 said in Is there any ways to change the outstyle of the window close button?:
Qt::FramelessWindowHint
I set the Qt::FramelessWindowHint attribute on the widget of the dockview,but it seemed useless.When the dockview object docked on the main window,the close button is still there ,and when it is floating out of the main window,the close button doesnt disappeared too.
-
@Pl45m4 said in Is there any ways to change the outstyle of the window close button?:
Qt::FramelessWindowHint
I set the Qt::FramelessWindowHint attribute on the widget of the dockview,but it seemed useless.When the dockview object docked on the main window,the close button is still there ,and when it is floating out of the main window,the close button doesnt disappeared too.
You could have mentioned, that we are dealing with a
QDockWidgethere.But almost the same answer:
Make your own title bar widget with your buttons and use -
You could have mentioned, that we are dealing with a
QDockWidgethere.But almost the same answer:
Make your own title bar widget with your buttons and useif(mode=="Default"||mode.isEmpty()){ // qDebug()<<"int UiPaneDockViewdetail::setTitleBarMode()-Default"; QWidget* t_TitleBar = this->titleBarWidget(); QWidget* t_DefaultWidget = new QWidget(); this->setTitleBarWidget(t_DefaultWidget); delete t_TitleBar; //t_TitleBar->hide(); } else if(mode=="Alone"){ qDebug()<<"int UiPaneDockViewdetail::setTitleBarMode()-Alone"; QWidget* t_TitleBar = this->titleBarWidget(); QWidget* t_DefaultWidget = new QWidget(); setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::CustomizeWindowHint); setTitleBarWidget(t_DefaultWidget); delete t_TitleBar; }I just want to switch the mode of the window between close button style and the no closed button style.You see the ALONE mode dosent work.I dont know why.Cause I dont know the way.
-
if(mode=="Default"||mode.isEmpty()){ // qDebug()<<"int UiPaneDockViewdetail::setTitleBarMode()-Default"; QWidget* t_TitleBar = this->titleBarWidget(); QWidget* t_DefaultWidget = new QWidget(); this->setTitleBarWidget(t_DefaultWidget); delete t_TitleBar; //t_TitleBar->hide(); } else if(mode=="Alone"){ qDebug()<<"int UiPaneDockViewdetail::setTitleBarMode()-Alone"; QWidget* t_TitleBar = this->titleBarWidget(); QWidget* t_DefaultWidget = new QWidget(); setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::CustomizeWindowHint); setTitleBarWidget(t_DefaultWidget); delete t_TitleBar; }I just want to switch the mode of the window between close button style and the no closed button style.You see the ALONE mode dosent work.I dont know why.Cause I dont know the way.
@nicker-player
I am jumping into this conversation, and know nothing aboutQDockWidget:)There are a few hits if you Google for
settitlebarwidgetwhich you might want to read through. there are obviously some "funnies" about dock titlebar widgets and different platforms.Please always tell us which platform you are on for questions like this.
Among these https://stackoverflow.com/q/28502134/489865 claims
Setting custom title bar widget changes the windows flags on Windows
See whether moving your
setWindowFlags()to after thesetTitleBarWidget()makes any difference? But your issue may be different from this. -
@nicker-player said in Is there any ways to change the outstyle of the window close button?:
setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::CustomizeWindowHint);I think these flags have no effect when using the title bar widget.
Try one from here: -
@nicker-player said in Is there any ways to change the outstyle of the window close button?:
setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::CustomizeWindowHint);I think these flags have no effect when using the title bar widget.
Try one from here:@Pl45m4
I found that the dockwidet only could be added by the qmainwindow object.But in fact I used the qwidget to add the dockwidget.Are there any problems to use like this?
And the way you just mentioned setFeatures dosent work.I dont know why.QWidget* t_TitleBar = this->titleBarWidget(); QWidget* t_DefaultWidget = new QWidget(this); setTitleBarWidget(t_DefaultWidget); setFeatures(QDockWidget::DockWidgetMovable |QDockWidget::DockWidgetFloatable |QDockWidget::DockWidgetClosable); delete t_TitleBar;