Results 1 to 16 of 16

Thread: qml can not recognize the c++ parameters with &

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: qml can not recognize the c++ parameters with &

    It is likely that the fileUrls property of FileDialog is actually of type QStringList, so passing the value to the C++ function might not involve any conversions.

    In which case passing by const reference would not create a copy. Even passing by value would be cheap since QList is implicitly shared (reference counted) so copying is a relatively cheap operation.

    Do you have any benchmark that shows the operation to be slow?

    Cheers,
    _

  2. #2
    Join Date
    Jan 2011
    Posts
    127
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default Re: qml can not recognize the c++ parameters with &

    It is likely that the fileUrls property of FileDialog is actually of type QStringList
    I hope so, but it is QList<QUrl> but not QList<QString>
    in the document of the FileDialog, there are nothing called fileUrl but filePath
    and the qml type of filePath is list<string>
    maybe this is because I am using 5.1RC, so the incoherent of the codes and the document still exist

    Even passing by value would be cheap since QList is implicitly shared (reference counted)
    Hard to said, because I need to modify the content of QList(sorting)

    Do you have any benchmark that shows the operation to be slow?
    No, it is not a bottleneck yet(maybe in the future, it is)
    but the experience from c++(and c) make me feel nervous
    when I have to copy the data which could be "moved" or take the reference usually

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: qml can not recognize the c++ parameters with &

    Quote Originally Posted by stereoMatching View Post
    I hope so, but it is QList<QUrl> but not QList<QString>
    I see, should still be ok. Your slot has the same type for its arguments.

    Quote Originally Posted by stereoMatching View Post
    Hard to said, because I need to modify the content of QList(sorting)
    Depends on the reference count at the time of modification. If the slot is the only one holding the list at that time it won't need to copy.
    If there is another owner, then there will be a copy of the list. Since you don't change the url data the QUrl instances should still be the same.

    Quote Originally Posted by stereoMatching View Post
    No, it is not a bottleneck yet(maybe in the future, it is)
    but the experience from c++(and c) make me feel nervous
    when I have to copy the data which could be "moved" or take the reference usually
    Due to the implicit sharing, copying is a lot like moving, actual copying happening on modification (copy on write).

    Cheers,
    _

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

    Default Re: qml can not recognize the c++ parameters with &

    Quote Originally Posted by anda_skoa View Post
    Depends on the reference count at the time of modification. If the slot is the only one holding the list at that time it won't need to copy.
    The reference count will not be 1 as the caller has a handle on the list as well.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2011
    Posts
    127
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default Re: qml can not recognize the c++ parameters with &

    I see, should still be ok. Your slot has the same type for its arguments.
    Because I want to make my question become easier to understand, I change the type of the example
    the real type are a little bit tricky, one is "QUrl" and another one is "QString"
    hope this could be fix in the release version

Similar Threads

  1. Qt5 don't recognize pri files !!?
    By alrawab in forum Newbie
    Replies: 4
    Last Post: 15th January 2013, 14:41
  2. Can't recognize the beforeInsert signal
    By scot_hansen in forum Newbie
    Replies: 0
    Last Post: 29th October 2010, 18:05
  3. How do I get Qt to recognize the oci driver.
    By yleesun in forum Qt Programming
    Replies: 11
    Last Post: 19th January 2009, 03:50
  4. How to recognize a letter from a Qstring?
    By luffy27 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2007, 19:22
  5. Getting Qt to recognize plugins...
    By KShots in forum Qt Programming
    Replies: 4
    Last Post: 21st April 2007, 10:05

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
  •  
Qt is a trademark of The Qt Company.