No, it's not. If you want to control the title, use QWidget::setWindowTitle(). As for the close button - it's part of the window manager and not your application so you can't modify it.
No, it's not. If you want to control the title, use QWidget::setWindowTitle(). As for the close button - it's part of the window manager and not your application so you can't modify it.
Thank you for reply, but I'm speaking about custom title and close button. They are implemented by me and all I want is possibility to style them due qss as it is done with QDockWidget. As a temporary workaround I found possibility to "address" this control with their object names, for example
Qt Code:
MyDialog#title { ......... } or MyDialog#closeButton { ... }To copy to clipboard, switch view to plain text mode
but this approach is less clear than MyDialog::title and it seems subcontrol-position and subcontrol-origin qss properties are not working, so question is still opened.
And I've got one more question: How to add :hover qss state to QWidget/QDialog subclass ?
You can't add your own style selectors to widgets. You can try to address QDialog:hover or MyDialog:hover but make sure first the widget receives hover events at all. But if the :hover state is not handled by QDialog, there is nothing you can do.
Probably I can't. But I've already added ability to be stylable with
"border-image" and "border-width" qss properties, which are not allowed for QDialogs according to the docummentation. All I need to do was:
Qt Code:
{ QStyleOptionFrame opt; opt.init(this); }To copy to clipboard, switch view to plain text mode
So, I'll try to continue experiments just in case if solution is not harder than code above. Probably deep investigation of QDockWidget internals will help.
It's your time, not mine. If you want to waste it - go ahead. The above works because you ask the style to draw the primitive for you. If you'd like :title to work, you'd have to again ask the style to draw the respective primitive for you and so your title would look like QDockWidget's which is probably not what you want, especially that the title is not drawn by some widget styles at all.
Bookmarks