Results 1 to 3 of 3

Thread: Add style to current

  1. #1
    Join Date
    Sep 2008
    Posts
    54
    Thanks
    3
    Thanked 10 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default Add style to current

    Hello,

    When I want an additional style effect to the current style of a widget all standard style elements are 'discarded'. How can I keep the current style and just add something?

    Example:

    I want the titleBar of a dockwidget to be green in the background:

    Qt Code:
    1. myDockWidget->setStyleSheet(QString::fromUtf8("QDockWidget::title { background: yellowgreen;}"));
    To copy to clipboard, switch view to plain text mode 

    The result is that I lose my original border and the text is placed on a different place.

    How can I prevent the loss of original styles?

    Regards,

    Marcel

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Add style to current

    Have you tried tried appending it to the current styles? Something like:
    Qt Code:
    1. myDockWidget->setStyleSheet( myDockWidget->styleSheet() + "\n" + QString::fromUtf8("QDockWidget::title { background: yellowgreen;}") );
    To copy to clipboard, switch view to plain text mode 
    Reversing this change will require keeping the old value.

  3. #3
    Join Date
    Sep 2008
    Posts
    54
    Thanks
    3
    Thanked 10 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default Re: Add style to current

    Hello,

    QString originalStyleSheet (myDockWidget->styleSheet());

    results in an empty string.

    Regards,

    Marcel

Similar Threads

  1. Do Qt Style Sheets support List-style-image?
    By daiheitan in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2010, 01:41
  2. Problems with Gradient style used through Style sheet on ARM platform
    By puneet.narsapur in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th January 2010, 12:48
  3. Get current ip address
    By Trok in forum Qt Programming
    Replies: 5
    Last Post: 16th March 2009, 23:08
  4. Replies: 1
    Last Post: 7th February 2007, 00:12
  5. Current KDE/Windows style
    By donmorr in forum Qt Tools
    Replies: 1
    Last Post: 19th May 2006, 17:49

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.