feat: config flag to avoid QtADS using Qt StyleSheet (#835)

Resolve: githubuser0xFFFF/Qt-Advanced-Docking-System#833
This commit is contained in:
Gary Wang
2026-04-24 04:44:23 +08:00
committed by GitHub
parent a9aa10f4c2
commit 985ff74ccf
3 changed files with 15 additions and 2 deletions

View File

@@ -779,6 +779,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
// uncomment if you would like to close tabs with the middle mouse button, web browser style // uncomment if you would like to close tabs with the middle mouse button, web browser style
// CDockManager::setConfigFlag(CDockManager::MiddleMouseButtonClosesTab, true); // CDockManager::setConfigFlag(CDockManager::MiddleMouseButtonClosesTab, true);
// uncomment if you would like to avoid using the built-in QSS stylesheet
// CDockManager::setConfigFlag(CDockManager::DisableStylesheet, true);
// Now create the dock manager and its content // Now create the dock manager and its content
d->DockManager = new CDockManager(this); d->DockManager = new CDockManager(this);
d->DockManager->setDockWidgetToolBarStyle(Qt::ToolButtonIconOnly, ads::CDockWidget::StateFloating); d->DockManager->setDockWidgetToolBarStyle(Qt::ToolButtonIconOnly, ads::CDockWidget::StateFloating);

View File

@@ -203,6 +203,10 @@ DockManagerPrivate::DockManagerPrivate(CDockManager* _public) :
//============================================================================ //============================================================================
void DockManagerPrivate::loadStylesheet() void DockManagerPrivate::loadStylesheet()
{ {
if (CDockManager::testConfigFlag(CDockManager::DisableStylesheet))
{
return;
}
initResource(); initResource();
QString Result; QString Result;
QString FileName = ":ads/stylesheets/"; QString FileName = ":ads/stylesheets/";

View File

@@ -64,8 +64,13 @@ struct AutoHideTabPrivate;
* of the docking system. The dock manager uses an internal stylesheet to * of the docking system. The dock manager uses an internal stylesheet to
* style its components like splitters, tabs and buttons. If you want to * style its components like splitters, tabs and buttons. If you want to
* disable this stylesheet because your application uses its own, * disable this stylesheet because your application uses its own,
* just call the function for settings the stylesheet with an empty * you can either set the DisableStylesheet config flag before creating
* string. * the dock manager:
* \code
* CDockManager::setConfigFlag(CDockManager::DisableStylesheet, true);
* \endcode
* Or call the function for settings the stylesheet with an empty string
* after creating the dock manager:
* \code * \code
* DockManager->setStyleSheet(""); * DockManager->setStyleSheet("");
* \endcode * \endcode
@@ -218,6 +223,7 @@ public:
DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget
TabsAtBottom = 0x20000000, //!< If the flag is set, tabs will be shown at the bottom instead of in the title bar. TabsAtBottom = 0x20000000, //!< If the flag is set, tabs will be shown at the bottom instead of in the title bar.
UseNativeWindows = 0x40000000, //!< If the flag is set, windows for the dock and area widgets will be native. UseNativeWindows = 0x40000000, //!< If the flag is set, windows for the dock and area widgets will be native.
DisableStylesheet = 0x80000000, //!< If the flag is set, the dock manager will not apply the default stylesheet
DefaultDockAreaButtons = DockAreaHasCloseButton DefaultDockAreaButtons = DockAreaHasCloseButton