×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    45

    Lineargradient conflicting with radius on qpushbutton

    Hi,

    I have a qpushbutton with a different lineargradient on the top, bottom, left and right, but whenever I try and put a radius in the corners it looks terrible, is there any better way to do this so that it still has the same gradients, but nicely rounded corners?

    I'm using the following stylesheet on the button: -

    QPushButton{
    background-color: rgb(0, 86, 118);
    border-style: solid;
    border-width: 13px;
    border-radius: 20px;
    border-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #00aaf2, stop: 1 #005676);
    border-left-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #00aaf2, stop: 1 #005676);
    border-bottom-color: qlineargradient(x1: 0, y1: 1, x2: 0, y2: 0, stop: 0 #00364c, stop: 1 #005676);
    border-right-color: qlineargradient(x1: 1, y1: 0, x2: 0, y2: 0, stop: 0 #00364c, stop: 1 #005676);
    font: bold 10px;
    min-height: 85px;
    min-width: 85px;
    }

    QPushButton:pressed{
    background-color: rgb(0, 86, 118);
    border-style: solid;
    border-width: 13px;
    border-radius: 20px;
    border-top-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #00364c, stop: 1 #005676);
    border-left-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #00364c, stop: 1 #005676);
    border-bottom-color: qlineargradient(x1: 0, y1: 1, x2: 0, y2: 0, stop: 0 #00aaf2, stop: 1 #005676);
    border-right-color: qlineargradient(x1: 1, y1: 0, x2: 0, y2: 0, stop: 0 #00aaf2, stop: 1 #005676);
    font: bold 10px;
    min-height: 85px;
    min-width: 85px;
    }

    Cheers,

    Northers
    Last edited by Northers666; 2010-05-18 at 13:53. Reason: QPushButton:pressed{ seemed to display with a smiley instead of :p

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Lineargradient conflicting with radius on qpushbutton

    Code:
    #include <QtGui>
    
    int main(int argc, char** argv)
    {
        QApplication app(argc, argv);
        app.setStyleSheet("QPushButton{background-color: rgb(0, 86, 118);"
                                      "border-style: solid;"
                                      "border-width: 20px;"
                                      "border-radius: 0px;"
                                      "border-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #00aaf2, stop: 1 #005676)"
                                                    "qlineargradient(x1: 1, y1: 0, x2: 0, y2: 0, stop: 0 #00aaf2, stop: 1 #005676)"
                                                    "qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #005676, stop: 1 #00aaf2)"
                                                    "qlineargradient(x1: 1, y1: 0, x2: 0, y2: 0, stop: 0 #005676, stop: 1 #00aaf2);}");
    
        QPushButton button("Test button");
        button.show();
    
        return app.exec();
    }
    It's probably easier to use a graphical texture:
    http://doc.trolltech.com/4.6/stylesh...ton-and-images

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    45

    Re: Lineargradient conflicting with radius on qpushbutton

    Hi,

    I tried using a graphical texture with the following line: -

    border-image: url(../qt/icons/blue_button.png) 2 2 2 2;

    My understanding is that the numbers at the end specify the size of the border in pixels and that the borders should not stretch as the button is resized. The larger the number I use the smaller the border I seem to get which I don't understand and regardless of what value I use it is stretched as the button is resized.

    Any ideas?

    Cheers,

    Northers

Similar Threads

  1. Conflicting stack sizes - again!
    By schm1 in forum Mobile Java General
    Replies: 7
    Last Post: 2005-10-08, 12:09
  2. 6230 Conflicting Applications
    By esan2 in forum Mobile Java General
    Replies: 0
    Last Post: 2005-06-27, 17:59
  3. Login script for RADIUS
    By torui in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2002-08-21, 23:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×