Results 1 to 3 of 3

Thread: change each separator's property

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Location
    Karlsruhe, Germany
    Posts
    57
    Thanks
    10
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default change each separator's property

    is there any way to set the width and color of each separator in QToolBar?

    Qt Code:
    1. toolBar -> setStyleSheet("QToolBar::separator { background-color: red; width: 30; height: 30px; }");
    To copy to clipboard, switch view to plain text mode 

    e.g the code above can only set general seperator property.

    Ive read some posts with possibly assigning an object name but failed.

    Qt Code:
    1. QAction* separator1 = toolBar->addSeparator();
    2. separator1->setObjectName("separator1");
    3.  
    4. toolBar -> setStyleSheet("QToolBar::separator#separator1 { background-color: red; width: 30; height: 30px; }");
    To copy to clipboard, switch view to plain text mode 

    it has no effect though...

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,258
    Thanks
    305
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: change each separator's property

    it has no effect though...
    Of course not. A QAction is an abstraction of a command, not a user interface element. It holds properties (like text or icons) that can be used by actual GUI elements (like toolbar buttons or menu items) to render themselves, but the QAction itself is just class to hold all these things in a convenient place. Giving it an object name doesn't give it magical powers.

    If the QToolBar class itself has no way to change the properties of individual separators, then you are stuck unless you want to write your own toolbar class derived from QToolBar. You will have to rewrite the paintEvent(), in particular the part that paints the separators. It probably will not be easy.

Similar Threads

  1. Change property of QInputDialog button
    By Raadush in forum Qt Programming
    Replies: 2
    Last Post: 11th July 2012, 13:50
  2. Replies: 1
    Last Post: 20th February 2012, 21:44
  3. Change Stylesheet Using Dynamic Property
    By stefanadelbert in forum Qt Programming
    Replies: 4
    Last Post: 26th August 2010, 08:48
  4. How to mark Property name in Q_PROPERTY for language change??
    By Ankitha Varsha in forum Qt Programming
    Replies: 7
    Last Post: 14th April 2010, 14:22
  5. Replies: 1
    Last Post: 18th February 2009, 09:34

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.