PDA

View Full Version : Intense Masking....



been_1990
25th April 2009, 13:18
IS there a way I can set masks for each QListView icon and text? So I'll have floating icons on the screen when set to Icon mode. Is there a way to get each icons x & y, width & heigth? Then mask them each time QListView is resized or the icon is moved? Thanks for the info!

Lykurg
28th April 2009, 15:07
Please can you specify or quickly draw a image of what you want achieve. To get the icons you have to ask your model and for the width & hight your delegate. (or QAbstractItemView::visualRect( const QModelIndex & ) etc.)

been_1990
28th April 2009, 22:02
This is a mock-code of what I want:


for each icon in QListView
get its x(), y(), width() and height()

pass it to a QRegion:
QRegion maskedRegion(x(),y(),width(),height(), QRegion::Rectangle);
set its Mask:
setMask(maskedRegion);

Something similar to these aero buttons (http://wiki.qtcentre.org/index.php?title=AeroButton)

wysota
28th April 2009, 22:22
Well, it didn't clarify anything to me, but QPixmap has methods for querying its width and height and you can retrieve position of each of the model indexes with QAbstractItemView::visualRect() (so you don't even need to ask for the pixmap size).

been_1990
29th April 2009, 13:19
This is the app without masking:
http://www.freewebs.com/yipsalon/site%20test/images/1.jpg

This is it with masking:
http://www.freewebs.com/yipsalon/site%20test/images/2.jpg
Images above were edited...

How can I use QAbstractItemView::visualRect()?
ui->QListView->what here?

Lykurg
29th April 2009, 14:20
Don't think you loading legal stuff with your eMule ;) And on your pictures I don't see any significant difference. Only in the second the background of your list view is transparent.. Don't get your intention.

wysota
29th April 2009, 15:01
This is the app without masking:
(...)

This is it with masking:
(...)

Please don't use external sites for storing images you refer to in your posts. Use the attachment feature of the forum instead.


How can I use QAbstractItemView::visualRect()?
Just as any other method - call it.


ui->QListView->what here?
Eeem.... "visualRect()" ?

been_1990
29th April 2009, 16:27
My intention is just that: mask each index icon so that they stay without the background.
I used external images because when I clicked the add-image it asked me for an url, so..
Thanks for all the help guys.. Ill try these out as soon as I can.

wysota
29th April 2009, 16:59
What does "stay without a background" mean? Icons don't have a background, it's transparent unless you paint it yourself.

been_1990
29th April 2009, 17:51
How do I get each index? ui->QListView->children()? Sorry if am asking too much, I havent found any tutorial or book that explains exactly this issue. Theres also QAbstractItemView::indexWidget ( const QModelIndex & index ) const thats seems to be related but I didnt quite understand what it does.

been_1990
29th April 2009, 17:58
I mean the app background, not the QListView background or icon background.

been_1990
29th April 2009, 19:30
In another attempt to explain what I want, here's a little illustration:
http://www.qtcentre.org/forum/attachment.php?attachmentid=3189&stc=1&d=1241026147

And I even learned how to use attachment!:p:D

wysota
29th April 2009, 23:46
You can use QWidget::setMask() although using Qt for the thing you are trying to do is not the smartest idea. I'd use widgets, mask them, bypass the window manager and reimplement their mouse events to handle moving them around.

Of course nothing will cause those objects to become real desktop icons so if this is what you are trying to obtain then Qt won't help you with that.

been_1990
30th April 2009, 04:47
So I wont be able to use QListView or any other thing to do that... awww.. But I could count files in a folder, get their MIME info, set a widget for each file, implement some click/right-click/double-click function, then set them in an ordered manner. Would that be too much work for something easily done with something else? Probably... Oh wel... I tried.. Thanks for all the help, I'll use then a simple QListView with a boring white background... Thanks!

wysota
30th April 2009, 10:19
You don't have to have a boring white background. You can make the background of your listview transparent (if your system supports it) so that your desktop shines through.

aamer4yu
30th April 2009, 10:37
Under windows you can have a look at Qt::WA_TranslucentBackground.
It will help you achieve what you want...

been_1990
30th April 2009, 15:59
I've searched many times here in the forum and on the net, and aparently I cant apply a transparent background, only to the whole app. of course the posts were outdated, but..
Where can I find Qt::WA_TranslucentBackground documentation? Its not in QtCreator Help. And does it really work?

@wysota: You can make the background of your listview transparent (if your system supports it)
Im using Win Vista. Is there any cross platform way? Thanks again.

spirit
30th April 2009, 16:25
I've searched many times here in the forum and on the net, and aparently I cant apply a transparent background, only to the whole app. of course the posts were outdated, but..
Where can I find Qt::WA_TranslucentBackground documentation? Its not in QtCreator Help. And does it really work?

have a look here (http://doc.trolltech.com/4.5/qt.html#WidgetAttribute-enum).

been_1990
30th April 2009, 16:39
Oh... Apparently thats only for QT4.5 and Im using QT4.4.3.. Lets start downloading...

spirit
30th April 2009, 16:40
yes, it's introduced in Qt 4.5.

been_1990
30th April 2009, 17:03
If I only knew that I had a outdated version.... I think I'll be fine from here. Thanks guys!! Alot! :D