Results 1 to 3 of 3

Thread: menu repaint

  1. #1
    Join Date
    May 2006
    Location
    Australia
    Posts
    53
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default menu repaint

    I want to get a background which fades from white to blue...easy...
    Qt Code:
    1. QPainter painter;
    2. painter.setPen(Qt::NoPen);
    3. painter.setBackgroundMode(Qt::TransparentMode);
    4.  
    5.  
    6. QLinearGradient grad(0, 300, 3000, 3000);
    7. grad.setColorAt(0, Qt::white);
    8. grad.setColorAt(1, Qt::blue);
    9. palette.setBrush(QPalette::Background, grad);
    To copy to clipboard, switch view to plain text mode 
    at least I thought it was easy, 'til I realised that my File/Edit menu titles were going black with black text when I rolled over them and when they were open the whole menu became black on black....

    the weird thing is, that if I relace that last line with
    Qt Code:
    1. palette.setBrush(QPalette::Background, Qt::blue);
    To copy to clipboard, switch view to plain text mode 
    everything is how you would expect it to be...
    I also changed QPalette::Background to QPalette::Window and the exact same thing happened

  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: menu repaint

    Some objects don't handle gradients and when you try to use one as a brush, you get a black solid brush instead. This might be the case here. Do you experience the same behaviour with other QStyles too? One of them might handle it...

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

    georgie (16th May 2006)

  4. #3
    Join Date
    May 2006
    Location
    Australia
    Posts
    53
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: menu repaint

    thanks
    yeah, you are right....the way I fixed it was to use a pixmap of a gradient i made in gimp instead :P is this cheating?
    works a charm now....thx

Similar Threads

  1. Docked Widget Menu
    By Chuk in forum Qt Programming
    Replies: 6
    Last Post: 3rd July 2013, 14:12
  2. QPushButton not calling repaint when needed?
    By Enygma in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2010, 17:03
  3. Replies: 4
    Last Post: 25th June 2007, 20:40
  4. MainWindow Menu bug in Qt 4.2.3?
    By No-Nonsense in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2007, 11:47
  5. Tracking separators in a menu (insertSeparator)
    By PrimeCP in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2006, 18:10

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.