Results 1 to 2 of 2

Thread: changing transparency of part of a qgraphicspixmap item

  1. #1
    Join Date
    Jun 2011
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default changing transparency of part of a qgraphicspixmap item

    Guys,

    i tried using qlinear gradient as the opacity mask for qgraphicsopacityeffect on a qgraphicspixmap item to change the transparency of certain region of the item like this


    /*******CODE STARTS
    //expose is the name of the qgraphicsopacityeffect variable
    //theRect defines the area where the opacity has to be changed
    // setGraphicsEffect(expose); has already been done

    QLinearGradient* theDude= new QLinearGradient(theRect.topLeft(),theRect.bottomRi ght();



    theDude->setColorAt(0,Qt::transparent);
    theDude->setColorAt(1.0,Qt::white);
    expose->setOpacityMask(*theDude);


    delete theDude;
    *************CODE ENDS******************************/


    but this code always ends up changing only the bottom right of the qgraphicspixmapitem no matter which rectangle is passed...
    where am i goin wrong... and in general, how do u change transparency of part of
    a qgraphicspixmapitem and leave the rest of the area unaffected;

  2. #2
    Join Date
    Jun 2011
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: changing transparency of part of a qgraphicspixmap item

    well, got the sol folks after some hrs of trial and error.... hope it can help someone out
    in the future.....

    QPainter* thePainter= new QPainter(&currentImage);

    thePainter->setOpacity(0.4);
    //pos is ur items pos.....
    thePainter->fillRect(theRect.topLeft().x()-pos().x(),theRect.topLeft().y()-pos().y(),theRect.width(),theRect.height(),Qt::bla ck);


    setPixmap(QPixmap::fromImage(currentImage));

    delete thePainter;

Similar Threads

  1. Changing a QGraphicsItem's transparency as a whole
    By blooglet in forum Qt Programming
    Replies: 4
    Last Post: 5th May 2011, 13:19
  2. changing state of previously selected list item
    By tyrnikeisari in forum Qt Quick
    Replies: 2
    Last Post: 26th March 2011, 06:47
  3. Changing selected QTreeView item font
    By dima1000 in forum Newbie
    Replies: 5
    Last Post: 8th October 2009, 09:28
  4. Replies: 1
    Last Post: 26th August 2009, 15:47
  5. Replies: 3
    Last Post: 12th April 2006, 09:35

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.