Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting Stylesheet for QDockWindow titlebar
Qt 6.11 is out! See what's new in the release blog

Setting Stylesheet for QDockWindow titlebar

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 427 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    I've set a stylesheet on the title bar of a QDockWidget thus:

    QDockWidget::title {background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(138, 185, 242, 0), stop:1 rgba(138, 185, 242, 255))}
    

    When I float it (at least in Qt Designer preview) the title bar background reverts to boring plain blue.

    Surely if I set a stylesheet, it should stick?

    David

    1 Reply Last reply
    0
    • PerdrixP Offline
      PerdrixP Offline
      Perdrix
      wrote on last edited by Perdrix
      #2

      The answer might be to use QDockWindow::setTitleBarWidget?

      Is there any sample code around for using that? Can I simply use a QLabel created thus:

      		QLabel* dockTitle{ new QLabel(this) };
      		QSize size{ 625, 25 };
      		dockTitle->setObjectName("dockTitle");
      		dockTitle->setMinimumSize(size);
      		dockTitle->resize(size);
      		dockTitle->setStyleSheet(QString::fromUtf8(
      			"background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, "
      			"stop:0 rgba(138, 185, 242, 0), stop:1 rgba(138, 185, 242, 255))"));
      		QString	text{ tr("Light Frames: %1      -      Dark Frames: %2      -      Flat Frames: %3      -   Dark Flat Frames: %4   -      Offset/Bias Frames: %5",
      			"IDS_LISTINFO")
      			.arg(0)
      			.arg(0)
      			.arg(0)
      			.arg(0)
      			.arg(0)
      		};
      		dockTitle->setText(text);
      

      Thanks again, D.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved