Results 1 to 2 of 2

Thread: paintEvent method problem

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default paintEvent method problem

    Hi,

    The code below draws the push button but not draws the focus rect with the desired color..Is there something wrong?

    Qt Code:
    1. 102 void CustomizedButton::paintEvent(...)
    2. 103 {
    3. 104 QStyleOptionButton buttonOptions;
    4. 105 buttonOptions.init(this);
    5. 106 buttonOptions.features = QStyleOptionButton::None;
    6. 107 buttonOptions.rect = rect();
    7. 108 buttonOptions.palette = palette();
    8. 109 buttonOptions.state = (isDown() ? QStyle::State_Sunken : QStyle::State_Raised);
    9. 110 style()->drawPrimitive(QStyle::PE_PanelButtonBevel, &buttonOptions, p, this);
    10. 111
    11. 112
    12. 113
    13. 114
    14. 115
    15. 116 QStyleOptionFocusRect frectOptions;
    16. 117 frectOptions.init(this);
    17. 118 frectOptions.palette.setColor(QPalette::Window, Qt::red);
    18. 119 frectOptions.rect = style()->subElementRect(QStyle::SE_PushButtonFocusRect, &buttonOptions, this);
    19. 120 if (hasFocus())
    20. 121 style()->drawPrimitive(QStyle::PE_FrameFocusRect, &frectOptions, p, this);
    21. 122 }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: paintEvent method problem

    Still no ideas?

    By the way if I do the following, it drows the border rect...

    Qt Code:
    1. QPen pen;
    2. pen.setStyle(Qt::SolidLine);
    3. pen.setColor(Qt::red);
    4. painter.setPen(pen);
    5. QRectF recta = style()->subElementRect(QStyle::SE_PushButtonFocusRect,
    6. &option,
    7. this);
    8. painter.drawRect(recta);
    To copy to clipboard, switch view to plain text mode 
    Last edited by zgulser; 8th April 2010 at 12:45.

Similar Threads

  1. paintEvent problem
    By di_zou in forum Newbie
    Replies: 5
    Last Post: 2nd September 2009, 16:13
  2. GraphicsView paintEvent() method implementation problem
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 2
    Last Post: 17th August 2009, 06:54
  3. Problem with QListWidget and paintEvent()
    By joksi in forum Qt Programming
    Replies: 2
    Last Post: 29th May 2009, 10:50
  4. paintEvent problem
    By anafor2004 in forum Newbie
    Replies: 1
    Last Post: 29th June 2008, 14:18
  5. paintEvent problem
    By MoaLaiSkirulais in forum Qt Programming
    Replies: 5
    Last Post: 12th February 2008, 13:59

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.