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. Add some customized menuButton on dockWidget titlebar with stylesheet
Forum Updated to NodeBB v4.3 + New Features

Add some customized menuButton on dockWidget titlebar with stylesheet

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 960 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.
  • S Offline
    S Offline
    simananzhui
    wrote on 11 Apr 2013, 08:41 last edited by
    #1

    hi
    I try to add some my menuButton on dockWidget titlebar using method <setTitleBarWidget>, mean i builded my dockwidget titlebar, but i found if i did not override the method <paintEvent>, my titlebar would never show, why? Is there some silmple way to do it like using stylesheet?

    BTW, my english is not good, please show me some codes to express your ideas, Thanks.

    [My code clips]

    @

    MyDockTitleBar *myTitleBar= new MyDockTitleBar(testDock);
    testDock->setTitleBarWidget(myTitleBar);

    void MyDockTitleBar::paintEvent(QPaintEvent*)
    {
    QPainter painter(this);
    QRect rect = this->rect();

    QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
    Q_ASSERT(dw != 0);
    
    if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
        QSize s = rect.size();
        s.transpose();
        rect.setSize(s);
    
        painter.translate(rect.left(), rect.top() + rect.width());
        painter.rotate(-90);
        painter.translate(-rect.left(), -rect.top());
    }
    
    painter.fillRect(rect.left(), rect.top(), rect.width(), rect.height(), QColor(tr("white")));
    painter.drawPixmap(rect.topRight() - QPoint(closePix.width() + 10, -10), closePix);
    painter.drawPixmap(rect.topRight() - QPoint(minPix.width() + 10 + closePix.width() + 10, -7), minPix);
    painter.drawPixmap(rect.topRight() - QPoint(floatPix.width() + 10 + minPix.width() + 10
                                                + closePix.width() + 10, -10), floatPix);
    

    }

    @

    1 Reply Last reply
    0

    1/1

    11 Apr 2013, 08:41

    • Login

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