Results 1 to 2 of 2

Thread: Qlist<pixmap> sembolList pass another class only via pointer.

  1. #1
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qlist<pixmap> sembolList pass another class only via pointer.

    I have QPixmaps array QList ,
    mainwindow.h file
    Qt Code:
    1. QList<QPixmap> sembolList;
    To copy to clipboard, switch view to plain text mode 
    mainwindow.cpp file
    Qt Code:
    1. sembolList << QPixmap(":/images/9_maca.png");
    2. sembolList << QPixmap(":/images/10_maca.png");
    3. sembolList << QPixmap(":/images/11_maca.png");
    4. ...
    5. ...
    To copy to clipboard, switch view to plain text mode 
    I want to send another classes (more than one) as constructor parameter sembolList but not instance or copy , only use its adress . in other words , I do not want to take up space in memory. one time create and dynamically use all my class. How to make that?
    Last edited by sevketk; 22nd December 2019 at 17:59.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qlist<pixmap> sembolList pass another class only via pointer.

    The QPixmap class is implemented with internal data sharing, so when you pass an instance of the class by value (as you are doing with QList< QPixmap >), the pixel data is -not- copied. So you can pass your QList<> by reference or by value. If you pass by value (QList<> mylist, instead of QList<> & mylist) then the only thing copied is the list itself. The QPixmap instances in the list are not copied, only their reference counts are incremented.

    See the "Detailed Description" in the QPixmap documentation and the "Implicit Sharing" overview in the Qt Core documentation.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 8th February 2018, 18:11
  2. Replies: 3
    Last Post: 23rd May 2015, 14:57
  3. pass QByteArray as a pointer
    By David_ in forum Newbie
    Replies: 3
    Last Post: 6th December 2012, 22:15
  4. how to pass a QList pointer
    By ehnuh in forum Qt Programming
    Replies: 2
    Last Post: 5th November 2012, 17:30
  5. Replies: 14
    Last Post: 1st December 2009, 21:45

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.