Results 1 to 2 of 2

Thread: Why are my QPushButtons slowly "blinking"?

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why are my QPushButtons slowly "blinking"?

    I have a Dialog with a GroupBox that contains several checkable QPushButtons that are not mutually exclusive.

    When the dialog is first shown, the background of the top button in the group slowly (cycle time a couple of seconds) changes from grey/white to light blue. When I click the button to make it "checked" the background stays solid blue (maybe slightly darker).

    Checking some (but not all) of the other buttons in the group box will stop the unchecked top button from blinking. When I check a button and uncheck it, that button stays blinking until I check another button.

    I don't want this behavior, since it make it hard to see a checked button versus one that's doing its blinky thing.

    I'm sure this is a newbie question, but I've read QPushButton documentation and can't figure out what's going on.

    The issue may be related to what I've set for icons. I have a "Normal On" icon defined for the top two buttons. That seems to create slightly different shading of the icon image for Normal Off, Disabled Off, Disabled on, active off, and active on. Interestingly, when I check the second button (which has an icon image) that doesn't stop the top button blinking. But checking the buttons that don't have an icon image causes the top button to stop blinking.

    I don't see this in Qt Designer Preview. It behaves just like I want in Designer--no blinking thing, the buttons highlight when I mouse over them, but they immediately go back to their original shading when the mouse moves off of them.

    What's going on? Where can I find documentation that explains?

    Hopefully, I don't have to create a slightly different version of the icon, shaded differently, for each of the states?

    Thanks,

    Dave Thomas


    Added after 1 2 minutes:


    I don't know why it was behaving the way it was, but I got what I want by setting focusPolicy to "NoFocus" in Qt designer.

    I understand about setting styles for each of the button states, eg. background. But I still don't understand the blinky thing. So, while I have a workaround, I'd like to understand better.

    Thanks,

    Dave Thomas
    Last edited by davethomaspilot; 10th February 2013 at 01:52.

  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: Why are my QPushButtons slowly "blinking"?

    This does not do what you describe for me on Linux:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Widget: public QGroupBox {
    4. Q_OBJECT
    5. public:
    6. Widget(QWidget *p = 0): QGroupBox("Test", p)
    7. {
    8. QVBoxLayout *layout = new QVBoxLayout(this);
    9. for (int i = 0; i < 5; ++i) {
    10. QPushButton *p = new QPushButton(this);
    11. p->setCheckable(true);
    12. layout->addWidget(p);
    13. }
    14. setLayout(layout);
    15. }
    16. };
    17.  
    18. int main(int argc, char **argv)
    19. {
    20. QApplication app(argc, argv);
    21. Widget w;
    22. w.show();
    23. return app.exec();
    24. }
    25. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    What's going on? Where can I find documentation that explains?
    If setting Qt::NoFocus on the buttons changes the behaviour then it seems likely the behaviour is related to keyboard focus. Given it is a QDialog this is likely related to default and autodefault buttons on the dialog
    Last edited by ChrisW67; 10th February 2013 at 22:32.

Similar Threads

  1. Replies: 1
    Last Post: 7th April 2010, 22:46
  2. Replies: 3
    Last Post: 15th February 2010, 18:27
  3. Replies: 3
    Last Post: 8th July 2008, 20:37
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 16:58

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.