Results 1 to 7 of 7

Thread: Custom Titlebar, Top-left, right border rounded; But left over part still visible

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Question Custom Titlebar, Top-left, right border rounded; But left over part still visible

    I've implemented a custom titlebar using QToolBar. I've applied the style to it as shown below.
    Qt Code:
    1. this->setStyleSheet("background: #646464; border: 0px; border-top-left-radius: 10px; border-top-right-radius: 10px;");
    To copy to clipboard, switch view to plain text mode 
    Now I got the rounded edges, but the left-over part after the border-radius is still visible. How do I "cut" it or How do I make it transparent ?
    Thank you.

  2. #2
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    52
    Thanks
    8
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Titlebar, Top-left, right border rounded; But left over part still visible

    paste the screen shot of your gui

  3. #3
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Custom Titlebar, Top-left, right border rounded; But left over part still visible

    Hi Pradeep,
    PFB the screenshot of TitleBar with rounded top-edges, with the residue part.
    Thank you.

    Titlebar.jpg
    Last edited by rawfool; 15th April 2013 at 14:06.

  4. #4
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    52
    Thanks
    8
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Titlebar, Top-left, right border rounded; But left over part still visible

    set same stylesheet for your base widget to cut top edges.

  5. #5
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Custom Titlebar, Top-left, right border rounded; But left over part still visible

    Hi Pradeep,

    I did apply the same stylesheet to the base widget also. But no luck. Pls find the code below. Thank you.

    Qt Code:
    1. CTitleBar::CTitleBar(QWidget *parent) :
    2. QToolBar(parent)
    3. {
    4. this->setFixedHeight(24);
    5. this->setWindowOpacity(100);
    6. this->setStyleSheet("background-color: #646464; border: 0px; border-top-left-radius: 8px; border-top-right-radius: 8px;");
    7. this->setContentsMargins(0, 0, 0, 0);
    8. setWidgetStyling();
    9. connect(closeButton, SIGNAL(clicked()), this, SIGNAL(sig_CloseButtonClicked()));
    10. }
    11.  
    12. void CTitleBar::setWidgetStyling()
    13. {
    14. holderWidget = new QWidget;
    15. holderWidget->setStyleSheet("background-color: transparent; border-top-left-radius: 8px; border-top-right-radius: 8px;");
    16. holderWidget->setMouseTracking(true);
    17. holderWidget->setContentsMargins(0, 0, 0, 0);
    18. this->addWidget(holderWidget);
    19.  
    20. titleLyt = new QHBoxLayout();
    21. titleLyt->setContentsMargins(0, 0, 0, 0);
    22. holderWidget->setLayout(titleLyt);
    23.  
    24. closeButton = new QToolButton();
    25. closeButton->setMouseTracking(false);
    26. closeButton->setText("X");
    27. closeButton->setContentsMargins(0, 0, 0, 0);
    28. closeButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
    29. closeButton->setFixedSize(20, 20);
    30. closeButton->setStyleSheet("QToolButton { color: white; font-size: 12px; background: #ec6c3f; border: 0px; border-radius: 8px;}"
    31. "QToolButton: hover { color: lightGray; background: #e44d2e; padding: 0px; border: 2px solid #f9d654;}"
    32. "QToolButton: pressed {color: lightGray; font-size: 9px; background: #ec633f; border: 0px solid #f9d456;}");
    33.  
    34. titleIcon = new QLabel();
    35. titleIcon->setPixmap(QPixmap(TRAY_ICON));
    36. titleIcon->setStyleSheet("border: none; background: transparent;");
    37.  
    38. titleText = new QLabel(APP_NAME);
    39. titleText->setContentsMargins(0, 0, 0, 0);
    40. titleText->setStyleSheet("color: orange; font: Arial; font-weight: bold; font-size: 12px");
    41.  
    42. titleLyt->addWidget(titleIcon);
    43. titleLyt->addWidget(titleText, 2);
    44. titleLyt->addWidget(closeButton);
    45. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    52
    Thanks
    8
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Titlebar, Top-left, right border rounded; But left over part still visible

    where your creating instance for CTitleBar set stylesheet for that widget.
    CTitleBar *pToolbar = new CTitleBar (this);
    this->setStyleSheet("background-color: transparent; border-top-left-radius: 8px; border-top-right-radius: 8px;");
    should work ...

  7. #7
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Custom Titlebar, Top-left, right border rounded; But left over part still visible

    I guess you are using the CTitleBar to replace the system provided title bar by using setWindowFlags(Qt::FramelessWindowHint) on the top level widget. In such case you also need to set the translucent attribute setAttribute(Qt::WA_TranslucentBackground); on the top level widget.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. Replies: 0
    Last Post: 24th August 2012, 09:29
  2. Replies: 7
    Last Post: 26th April 2012, 14:45
  3. Replies: 4
    Last Post: 29th August 2010, 18:16
  4. Replies: 2
    Last Post: 5th July 2008, 19:35
  5. Rounded Dialog and Titlebar
    By ntp in forum Qt Programming
    Replies: 1
    Last Post: 20th June 2008, 21:49

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.