Results 1 to 6 of 6

Thread: How can we paint image on slider?

  1. #1
    Join Date
    Aug 2011
    Location
    Bangalore, India
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows Symbian S60

    Default How can we paint image on slider?

    I want to paint image on slider groove and slider handle individually.

  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: How can we paint image on slider?

    I'm assuming your question is "where do I start". Basically you have two choices, to subclass the slider and reimplemnt thebpaint event to draw something ON the groove or implement a subclass of QStyle to draw something INSTEAD of the groove.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2011
    Location
    Bangalore, India
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows Symbian S60

    Default Re: How can we paint image on slider?

    but if i will re implement the paint event can i paint groove and handle each with different image.

  4. #4
    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: How can we paint image on slider?

    If you reimplement the paint event, you can paint whatever you want. You can even not paint at all. Also consider using stylesheets instead of reimplementing the event.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2011
    Location
    Bangalore, India
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows Symbian S60

    Default Re: How can we paint image on slider?

    stylesheet i have tried but it is not as flexible as i want.Can you please tell me how i will paint on the handle of the slider. what position i will give suppose if i am using the following code
    Qt Code:
    1. void custom_slider::paintEvent (QPaintEvent *ev)
    2. {
    3. QPainter painter(this);
    4. painter.drawPixmap (QRectF(?,?,94,17), pixmap,QRectF(0,0,94,17));
    5. painter.drawPixmap (QRectF(?,?,7,7),pixmap1,QRectF(0,0,7,7));
    6.  
    7. }
    To copy to clipboard, switch view to plain text mode 

    where pixmap is the image for groove.
    pixmap1 for handle of slider.

  6. #6
    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: How can we paint image on slider?

    It's not that easy. You need to calculate those positions. However it will probably be simpler to implement it in QProxyStyle subclass.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How can we make slider form the two image?
    By pratik041 in forum Qt Programming
    Replies: 0
    Last Post: 29th October 2011, 09:54
  2. How to Display/Paint raw image data.
    By vinaykusta in forum Qt Programming
    Replies: 5
    Last Post: 12th October 2011, 14:01
  3. Replies: 2
    Last Post: 21st March 2010, 09:01
  4. Painter greyscale, image quality paint-brush!
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 22nd March 2007, 20:32
  5. Paint Rect visible on Drag to crop image coordinate
    By patrik08 in forum Qt Programming
    Replies: 8
    Last Post: 17th March 2007, 09:04

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.