Results 1 to 11 of 11

Thread: Subclass and Connections

  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Subclass and Connections

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclass and Connections

    Please tell me can we use both concept of Subclass and connections (Signals and Slots ) together.
    What do you mean

    If yes then How ? Explain with an example.
    We are not giving any test
    We can't solve problems by using the same kind of thinking we used when we created them

  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Subclass and Connections

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Subclass and Connections

    I'm just like Sunil, I don't understand your request...

    Explain with a little example

  5. #5
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Subclass and Connections

    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclass and Connections

    Why do you want to use Subclassing for this. ? reverse_images can check the state of the item passes and toggle the images.
    We can't solve problems by using the same kind of thinking we used when we created them

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Subclass and Connections

    This thread is related to this one:
    http://www.qtcentre.org/forum/f-qt-p...ages-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.

  8. The following user says thank you to wysota for this useful post:

    merry (6th March 2007)

  9. #8
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Subclass and Connections

    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

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Subclass and Connections

    Quote Originally Posted by merry View Post
    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?

  11. #10
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Subclass and Connections

    Thanx

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

    merry

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Subclass and Connections

    Take a look at the tutorial I mentioned. Some things should become clear when you do.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.