Results 1 to 6 of 6

Thread: Why there are always dashed-line rectangle on QToolButton?

  1. #1
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Why there are always dashed-line rectangle on QToolButton?

    I added a QToolButton onto a QToolBar. But the first button always has the dashed line ractangle around it. Even if I click other button, the first button still has that rectangle. I don't know how to remove it. Here I set each QToolButton as following code:
    Qt Code:
    1. action = new QAction(this);
    2. action->setIcon(icon);
    3. action->setCheckable(true);
    4. actionGroup->addAction(action);
    To copy to clipboard, switch view to plain text mode 
    And then I create the QToolButton:
    Qt Code:
    1. QToolButton * createToolButton(QAction *action)
    2. {
    3. QToolButton *button = new QToolButton;
    4. button->setDefaultAction(action);
    5. button->setAutoRaise(true);
    6. return button;
    7. }
    8. // ...
    9. QToolButton *button = createToolButton(action);
    10. layout->addWidget(button , 0, 0, 1, 1);
    11. // other butttons
    To copy to clipboard, switch view to plain text mode 
    Please help me. Thank you all!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Why there are always dashed-line rectangle on QToolButton?

    This is called "keyboard focus". Anyway, you shouldn't create tool buttons for actions yourself. Just add the action to a toolbar and a tool button will be created for you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    FinderCheng (23rd October 2009)

  4. #3
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why there are always dashed-line rectangle on QToolButton?

    Yeah, I know I could add QAction onto QToolBar directly. But I want to have a grid-like tool bar with two columns. I don't know how to implement it so I added a QWidget with QGridLayout and then added this widget into tool bar therefore I have to create QToolButton myself.
    Then how to remove this key focus or how to add actions into a tool bar with mutil-columns?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Why there are always dashed-line rectangle on QToolButton?

    You can try setting the focus policy for each of the buttons to NoFocus.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    FinderCheng (23rd October 2009)

  7. #5
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why there are always dashed-line rectangle on QToolButton?

    Thanks! It works! Hope there is no side effects... :-)

  8. #6
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Why there are always dashed-line rectangle on QToolButton?

    The side effect is that you disabled keyboard navigation.
    It's nice to be important but it's more important to be nice.

Similar Threads

  1. Why is my application's CPU usage always > 50%
    By richardander in forum Qt Programming
    Replies: 10
    Last Post: 14th October 2010, 22:22
  2. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 13:51
  3. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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.