Results 1 to 9 of 9

Thread: Flat Icon in a QToolBar

  1. #1
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Flat Icon in a QToolBar

    I am using a QToolbar in a frame where I would like to display the icons in a flat mode. I did not found what I have to set for getting the flat representation.

    If someone has an idea...
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Flat Icon in a QToolBar

    Set the QToolButtons flat.

    EDIT: Too fast, only QPushButton can be set flat. So you could set css "border:0;" to the QToolButton with the same effect.

  3. #3
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flat Icon in a QToolBar

    Set QToolButton::autoRise to true. It causes the ToolButton to be flat and only raise when the mouse hovers over it.

  4. #4
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Flat Icon in a QToolBar

    What I am currently doing is:
    - create the action
    - add the action to the toolBar by using the addAction method

    Is there a way to access the QToolButton that is created automatically when the action is added to the toolbar with QToolBar::addAction() ?

    Or should I:
    - create the action
    - create the toolButton
    - set the default action of the toolButton
    - add the toolButton to the toolBar

  5. #5
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Flat Icon in a QToolBar

    u can use
    QAction * QToolBar::addWidget ( QWidget * widget )
    to set a pushbutton..(for setFlat())

    is there a way to access the QToolButton that is created automatically when the action is added to the toolbar with QToolBar::addAction() ?
    QWidget * widgetForAction ( QAction * action ) const

  6. #6
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Flat Icon in a QToolBar

    The following code did not change the way it is presented.

    Qt Code:
    1. void
    2. TitleFrame::addAction ( QAction * action ){
    3. if (m_useToolbar) {
    4. m_toolbar->addAction(action);
    5. QToolButton* toolButton = (QToolButton*)m_toolbar->widgetForAction(action);
    6. toolButton->setAutoRaise(true);
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    So I guess what I am seeing could be just the border for the entire QToolBar widget ?

  7. #7
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Flat Icon in a QToolBar

    So I guess what I am seeing could be just the border for the entire QToolBar widget ?
    test it by adding few more widgets like combobox

  8. #8
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Flat Icon in a QToolBar

    Mmmm. Ok it is is the border of the entire QToolBar I was seeing.
    Now I am looking how to remove this one.
    Attached Images Attached Images

  9. #9
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Flat Icon in a QToolBar

    Ok, I was able to remove the border with the following CSS rule:

    Qt Code:
    1. border: 0px;
    2. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

Similar Threads

  1. QMessageBox missing icon
    By zanth in forum Qt Programming
    Replies: 3
    Last Post: 8th July 2010, 21:20
  2. Mac application and the Dock Icon
    By sekelsenmat in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2007, 10:23
  3. Various icon sizes for QToolButtons on QToolbar
    By Erlendhg in forum Qt Programming
    Replies: 4
    Last Post: 30th June 2007, 18:35
  4. QToolBar icon size
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 29th March 2007, 13:12
  5. QPushbutton Flat property and icon appearance.
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 4th November 2006, 08:30

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.