Results 1 to 1 of 1

Thread: implement object comparison in C++

  1. #1
    Join Date
    Jan 2015
    Posts
    6
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: implement object comparison in C++

    Hello,

    I am trying to determine whether it is possible to implement QObject types such that they provide "logical equality". By this I mean, that 2 objects that are physically different can be determined to be representing the same application value (in my case, the QObjects are wrapping non-Q application objects). I would like to write the comparison as
    Qt Code:
    1. Component.onCompleted: {checked = (selectedProject == project)}
    To copy to clipboard, switch view to plain text mode 
    my investigations so far have shown that this is impossible because comparison operators in Javascript cannot be overloaded. Since I cannot ensure the uniqueness of the QObject wrappers, I will have to go with a "sameAs" Q_INVOKABLE methd, and change the QML/Javascript code to
    Qt Code:
    1. Component.onCompleted: {checked = selectedProject.sameAs(project)}
    To copy to clipboard, switch view to plain text mode 

    any commmments?
    thanks,
    chris
    Last edited by gsv-chris; 19th February 2015 at 14:11.

Similar Threads

  1. Comparison of objects from QList
    By Rich1234 in forum Newbie
    Replies: 4
    Last Post: 20th June 2014, 13:44
  2. Problem QT : Comparison from the base
    By anouar2002 in forum Newbie
    Replies: 4
    Last Post: 22nd February 2012, 23:20
  3. QByteArray comparison
    By giusepped in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2011, 10:02
  4. file name comparison
    By mentalmushroom in forum Qt Programming
    Replies: 10
    Last Post: 15th March 2011, 22:54
  5. String comparison
    By Sarma in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2006, 12:31

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.