Results 1 to 8 of 8

Thread: transparent pixmap

  1. #1
    Join Date
    May 2010
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default transparent pixmap

    Hi!

    Im trying to create an transparant pixmap to use in a listview. The best result I get is to use createHeuristicMask which isn't good enough.

    I have been trying to fill the pixmap with an transparent image first, but not succeceded.

    Im using Qt 3.3 and here is the code that im trying to experiment with at the moment.

    #include <qapplication.h>
    #include <qlistview.h>
    #include <qpainter.h>
    #include <qpixmap.h>
    #include <qbitmap.h>

    int main ( int argc, char **argv )
    {

    QApplication app ( argc,argv );

    QListView *listview=new QListView();
    listview->addColumn ( "test" );

    QListViewItem *item1=new QListViewItem ( listview );
    item1->setText ( 0,"testing text" );

    QListViewItem *item2=new QListViewItem ( listview );
    QPixmap pixmap ( 150,50 );
    pixmap.fill ( Qt::white );
    QPainter painter ( &pixmap );
    painter.drawText ( 15,15,"testing pixmap" );
    painter.end();
    pixmap.setMask(pixmap.createHeuristicMask());
    item2->setPixmap ( 0,pixmap );

    app.setMainWidget ( listview );
    listview->show();

    return app.exec();
    }

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: transparent pixmap

    What's about
    Qt Code:
    1. pixmap.fill ( Qt::color0 );
    To copy to clipboard, switch view to plain text mode 
    ? Does that work?

  3. #3
    Join Date
    May 2010
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: transparent pixmap

    nope, that didn't work

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: transparent pixmap

    What class is QListViewItem ? Its not a standard Qt class.
    also seems you want a common background for the list view and hence you want the transparent pixmap for the item, am i right ??

  5. #5
    Join Date
    May 2010
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: transparent pixmap

    QListViewItem is defined in listview.h in Qt 3.3 in Linux. (QListViewItem is not an QWidget, just a helper for QListView)

    Yes, I want to create a pixmap with transparant background, so the background of the listview is still visible (or actually the listviewitem, which can be blue (selected) or white (not selected))

    I have been able to load a png-file with transparant background, and then load it in to the listview, this works exacly the way I want't it to.

    createHeuristicMask() works, but the output is very ugly. and letters wich surround white areas, such as "0" or "6" doesn't get transparent.

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: transparent pixmap

    Qt 3.3 :O

    wud suggest to upgrade to 4.6.3 unless you have some boundations.
    4.7 is also coming this year...

  7. #7
    Join Date
    May 2010
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: transparent pixmap

    ok, i will try qt463. can you recommomend any beginner guide for people used to 3.3?

  8. #8
    Join Date
    May 2010
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: transparent pixmap

    qt 4.6.2 seems to be installed on my ubuntu.. good enough?

Similar Threads

  1. Semi-transparent QDrag pixmap
    By Jugdish in forum Qt Programming
    Replies: 0
    Last Post: 1st October 2009, 11:10
  2. QListWidget transparent background or pixmap
    By wdezell in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2009, 17:53
  3. Non-transparent QWidget on semi-transparent parent
    By EuroElessar in forum Qt Programming
    Replies: 0
    Last Post: 29th August 2008, 16:20
  4. Transparent background on QLabel on transparent QWidget
    By codeslicer in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 02:10
  5. Transparent Pixmap
    By maverick_pol in forum Qt Programming
    Replies: 6
    Last Post: 19th December 2007, 16:25

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.