PDA

View Full Version : path to qt source



sajis997
5th August 2011, 19:34
Hello forum

I have the Qt 4.4 installed in Ubuntu 8.10 through the repository.

I need to get some of the source files .cpp to get to see some function definition. So far i have found the header files under


/usr/include/qt4/Qt/


i need to get to the Qt source files of all these header files.

Thanks
Sajjad

SixDegrees
5th August 2011, 19:53
There's no reason you should have the source files; they're not needed for normal uses. You'll probably only have them if you've installed the development packages.

Try looking for a likely candiate, with something like 'locate qsound.cpp'. If you come up empty, you'll need to install the development packages.

sajis997
5th August 2011, 21:16
Hi

I needed to know how to use the data() function for the QGraphicsItem class. Do you know any example that over-ridden this function?

The small snippet inside thE Qt Assistant seems not to be enough for me to understand.


Thanks
Sajjad

SixDegrees
5th August 2011, 21:48
From the documentation:


Custom item data is useful for storing arbitrary properties for any item. Qt does not use this feature for storing data; it is provided solely for the convenience of the user.

So you can stuff an arbitrary item of data of any type understood by QVariant into a QGraphicsItem, and retrieve it later. This might be useful if you need to keep track of a single value - a user's name, for example, or a floating point value or some such - instead of deriving your own class to hold a more complex assortment of data.

wysota
6th August 2011, 00:15
Furthermore the method is not virtual so overriding it doesn't make any sense. And the source code for the method will not do you much good, here it is:

QVariant QGraphicsItem::data(int key) const
{
QGraphicsItemCustomDataStore *store = qt_dataStore();
if (!store->data.contains(this))
return QVariant();
return store->data.value(this).value(key);
}