Sunday, August 14, 2011

Running vmware-tools on Fedora 14

I was having some trouble installing vmware-tools.

First run uname -r to see the kernel version you're running.
Then make sure that the following packages match your kernel

kernel-headers
kernel-devel
-----------------------------------------------------------
sudo yum install kernel-headers-`uname -r`
sudo yum install kernel-devel-`uname -r`
-----------------------------------------------------------

If your kernel-headers version is more recent than your kernel, just remove it, then reinstall it specifying the version. That should do it.
Again, hope this helps someone.

Tuesday, January 25, 2011

Disabling QCombobox items

So I ran into the problem in Qt a while back of not being able to disable certain items in a QComboBox widget. Since when I was looking for it I couldn't find a solution, I figured I'd post the solution here even though nobody will probably ever read it.

You have to use the QAbstractItemModel's setFlags() method. Wait, what do you mean there's no setFlags() method? Oh, well just use the setData() method and have the role as 'Qt::UserRole - 1'. Because that makes so much sense. bleh. I hope qt fixes that.

Unfortunately I can't take a screenshot of it right now. But here's my solution anyways. Hope this helps somebody.


----------------------------------------------------------------------------------------------------------------
// Get the index of the value to disable
QModelIndex index = ui.comboBox->model()->index(1,0);

// This is the effective 'disable' flag
QVariant v(0);
//the magic

ui.comboBox->model()->setData( index, v, Qt::UserRole -1);
----------------------------------------------------------------------------------------------------------------