PDA

View Full Version : Subclass and Connections



merry
6th March 2007, 06:25
Hi all

Please tell me can we use both concept of Subclass and connections (Signals and Slots ) together . If yes then How ? Explain with an example.


Thanx and Regards
merry

sunil.thaha
6th March 2007, 09:23
Please tell me can we use both concept of Subclass and connections (Signals and Slots ) together. What do you mean :confused:



If yes then How ? Explain with an example.
We are not giving any test ;)

merry
6th March 2007, 09:39
Mr Sunil

I Know U people are not giving anykind of test.;)

I just simply asked u people that can we use connections and Subclassing together becoz
I didnt know about this if u people know about this then tell me , dats it.:)


merry

guilugi
6th March 2007, 10:55
I'm just like Sunil, I don't understand your request...

Explain with a little example :)

merry
6th March 2007, 11:24
Hi

Exactly My Problem is that
I am having a treeStructure of Files and Folders and I had represented files and folders with different different images.

Foreg.


Files are represented by Fileunchecked.png
Folders are represented by Folderunchecked.png
now when i pressed any File or Folder it can be replaced by another image like


Fileunchecked.png is replaced by Filechecked.png
and
Folderunchecked.png is replaced by Folderchecked.png

For this I used the concept of Connections using Signals and Slots


connect(listView,SIGNAL(pressed(QListViewItem*)),t his,SLOT(reverse_images(QListViewItem*)));

By using this the images are changed.

But now I want when I again Click on any File or Folder (that are checked) can be replaced by File or Folder (that are unchecked)

That is


Filechecked.png is replaced by Fileunchecked.png
and
Folderchecked.png is replaced by Folderunchecked.png


Actually i want to flip the image back to the one that was there before. For this I want to use the concept of Subclassing. But I dont know how to use. If you understand my Problem then Please tell me How can I use Subclassing for this.Hope You can understand what I want to say. :)

sunil.thaha
6th March 2007, 11:45
Why do you want to use Subclassing for this. ? reverse_images can check the state of the item passes and toggle the images.

wysota
6th March 2007, 12:18
This thread is related to this one:
http://www.qtcentre.org/forum/f-qt-programming-2/t-replacement-of-images-5835.html

I really suggest to learn a little of C++ before starting with Qt...

Merry - in practice you can't use signal/slot connections without subclassing as all classes that use signals and slots inherit QObject class which implements signals and slots mechanism. So to answer your question - yes, it is possible to both subclass and use signals and slots. Still, I suggest to read a little about inheritance and polymorphism.

merry
6th March 2007, 12:38
yaa

WySota I know little about C++ and also know About inheritance but dont Know How to implement it in Qt.

Wysota I just want to make u request that please help me in learning Qt.
I m a beginner in Qt and know very little about Qt.

Thanx merry

wysota
6th March 2007, 13:03
WySota I know little about C++ and also know About inheritance but dont Know How to implement it in Qt.
You don't "implement" inheritance in Qt - inheritance is part of the C++ language - just use it.


Wysota I just want to make u request that please help me in learning Qt.
I m a beginner in Qt and know very little about Qt.

Your problem is C++, not Qt. Did you take a look at Johan's Independent Qt Tutorial (http://digitalfanatics.org/projects/qt_tutorial/)?

merry
6th March 2007, 13:16
Thanx

Now i ll try to first learn C++ and Then Qt

merry

wysota
6th March 2007, 13:19
Take a look at the tutorial I mentioned. Some things should become clear when you do.