Results 1 to 6 of 6

Thread: Replacement of Images

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

    Default Replacement of Images

    HiHi all

    I am using Qt3.1 for Linux Operating System.

    My Problem is that how can I replace one image with another,

    By using Connections(Signals and Slots)

    connect(listView,SIGNAL(pressed(QListViewItem*)),t his,SLOT(reverse_images(QListViewItem*)));
    it can replace images.

    But what I want is after replacing images when I pressed again on an item it can again replace image with the first one(initial one).

    Pls do reply with an eg.

    Thanx and Regards
    merry
    Last edited by merry; 26th February 2007 at 09:41. Reason: missing [code] tags

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

    Default Re: Replacement of Images

    But what is the problem exactly? What did you already try?

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

    Default Re: Replacement of Images

    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 also 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

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

    Default Re: Replacement of Images

    I still don't see a problem... Just extend your method to flip the image back to the one that was there before. If you want to make the task easier, you can subclass the list item and introduce an additional member holding the item state (checked/unchecked).

    BTW. Why not use QCheckListItem instead? You can subclass it and draw a pixmap instead of a checkbox.

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

    Smile Re: Replacement of Images

    Hi Wysota

    Actually i m new to Qt3.1 , So can you Please explain the use of Subclass with example

    Thanx
    Merry

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

    Default Re: Replacement of Images

    Are you familiar with C++ and its concept of inheritance? Your problem is strictly C++.

    http://www.mindview.net/Books/TICPP/...ngInCPP2e.html

Similar Threads

  1. Displaying real time images
    By Sheetal in forum Qt Programming
    Replies: 9
    Last Post: 22nd February 2007, 11:29
  2. How to display images in QTextBrowser ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 08:58
  3. Replies: 1
    Last Post: 5th December 2006, 11:07
  4. JPEG Images not shown in QiconView using QT3??
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2006, 20:34
  5. working with images
    By Kapil in forum Newbie
    Replies: 2
    Last Post: 9th March 2006, 11:59

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.