This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Ruby setFlags

Tags: None
(comma "," separated)
User avatar
jovin
Registered Member
Posts
33
Karma
0
OS

Ruby setFlags

Tue Feb 05, 2013 5:45 pm
How does setFlags work for Ruby?

I can't get the following working:
Code: Select all
item = Qt::ListWidgetItem.new
item.setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Ruby setFlags

Fri Feb 08, 2013 10:23 am
Can you please provide the error message you are encountering?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
jovin
Registered Member
Posts
33
Karma
0
OS

Re: Ruby setFlags

Fri Feb 08, 2013 1:09 pm
Well, there is no error message.
The item just greys out (becomes unselectable).
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Ruby setFlags

Fri Feb 08, 2013 8:32 pm
What happens if you just pass Qt::ItemIsSelectable? I suspect the | may be triggering an or operation, instead of combining the two enumerators as it would in C++.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
jovin
Registered Member
Posts
33
Karma
0
OS

Re: Ruby setFlags

Fri Feb 08, 2013 9:17 pm
bcooksley wrote:What happens if you just pass Qt::ItemIsSelectable? I suspect the | may be triggering an or operation, instead of combining the two enumerators as it would in C++.

Nope. That doesn't do it either.
But I tried something different and well...
Code: Select all
item = Qt::ListWidgetItem.new
puts item.flags # => 53

Okay thats good to know.
So I tried...
item.setFlags(54)
puts item.flags # => 54

And the item is editable!
Looking at this table:
Code: Select all
Qt::NoItemFlags   0   It does not have any properties set.
Qt::ItemIsSelectable   1   It can be selected.
Qt::ItemIsEditable   2   It can be edited.
Qt::ItemIsDragEnabled   4   It can be dragged.
Qt::ItemIsDropEnabled   8   It can be used as a drop target.
Qt::ItemIsUserCheckable   16   It can be checked or unchecked by the user.
Qt::ItemIsEnabled   32   The user can interact with the item.
Qt::ItemIsTristate   64   The item is checkable with three separate states.

53 is a combination of 1, 4, 16 and 32 with 2 (Qt::ItemIsEditable) missing.
Meaning that setting the flag to 55 it would include 2 as well and thus enabling the Qt::ItemIsEditable flag!
Though 54 already enables editing, so I'm not so sure about my explanation, but that makes the most sense to me.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Ruby setFlags

Fri Feb 08, 2013 9:39 pm
Good to see you found a solution, although ideally one should have been able to use the enumerators Qt provides.
I suspect 54 means Qt::ItemIsEditable (2), Qt::ItemIsDragEnabled (4), Qt::ItemIsUserCheckable (16) and Qt::ItemIsEnabled (32).


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient