Results 1 to 19 of 19

Thread: How to set my QPushbutton's background?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set my QPushbutton's background?

    and if I set the add this code:
    Qt Code:
    1. colorButton->setFlat(true);
    To copy to clipboard, switch view to plain text mode 

    the button's background wiil be set.
    but I don't want to set the flat true!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set my QPushbutton's background?

    Quote Originally Posted by cspp View Post
    and if I set the add this code:
    Qt Code:
    1. colorButton->setFlat(true);
    To copy to clipboard, switch view to plain text mode 

    the button's background wiil be set.
    but I don't want to set the flat true!
    I did change flatness of a button, just compiled your example and it works.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set my QPushbutton's background?

    btw, I tested on Qt 4.5.0, which version of Qt do you use?
    PS. also read this, maybe you already know this.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  4. #4
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set my QPushbutton's background?

    QMake version 2.01a
    Using Qt version 4.3.2 in D:\Qt\4.3.2\lib

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set my QPushbutton's background?

    Quote Originally Posted by cspp View Post
    QMake version 2.01a
    Using Qt version 4.3.2 in D:\Qt\4.3.2\lib
    maybe this is a bug in this Qt version, try to compile you code with older Qt version.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set my QPushbutton's background?

    Quote Originally Posted by spirit View Post
    maybe this is a bug in this Qt version, try to compile you code with older Qt version.
    I compiled my code in QT4.5,
    it works well.

    I think it just some Bug in Qt4.3.2!

  7. #7
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set my QPushbutton's background?

    yup, I don't remember the task number, but it was on the tracker.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. #8
    Join Date
    Apr 2009
    Posts
    21
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to set my QPushbutton's background?

    I followed the exact code to update the QPalette to change the QPushButton's color but it never showed the color. I compiled my code for Qt 4.5.3 on *both* Unix/X11 and Qt-Embedded, none worked I tried Qt Designer as well, color's not shown either. It works with style sheet, but what I'm trying to have a blinking button that changes colors ever 0.5s, and just that eats up 95% CPU consumption! Admittedly we don't have a very powerful one so I was hoping using QPalette would help the performance.

    Anyhow, do you guys have any more ideas? I do have a style sheet applied at the top level Form, but it should be overwritten when I update palette for a particular button, right?

    Thanks in advance.

  9. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set my QPushbutton's background?

    can you show us you code?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  10. #10
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: How to set my QPushbutton's background?

    In my example,I use the setStyleSheet,it works well.But in my application,it will be crashed!
    I have no idea

    the crash infomation is:
    Qt has caught an exception thrown from an event handler. Throwing
    exceptions from an event handler is not supported in Qt. You must
    reimplement QApplication::notify() and catch all exceptions there.

    Qt has caught an exception thrown from an event handler. Throwing
    exceptions from an event handler is not supported in Qt. You must
    reimplement QApplication::notify() and catch all exceptions there.
    In my application,I have a framework,it will be load some QLibrary,in the
    Lib,it wil create some widget,like QPushButton,like the listColorBtn.
    and now when I setStyleSheet in listColorBtn,it crashed!

Similar Threads

  1. Replies: 5
    Last Post: 21st July 2010, 22:51
  2. Replies: 2
    Last Post: 10th February 2009, 13:12
  3. QLCDNumber with transparent background?
    By PolyVox in forum Qt Programming
    Replies: 2
    Last Post: 20th October 2008, 05:34
  4. background colour
    By kw in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2006, 00:44
  5. Replies: 1
    Last Post: 5th April 2006, 16:44

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.