Results 1 to 4 of 4

Thread: Does sizeof() operator work with QT Objects?

  1. #1
    Join Date
    Sep 2013
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Exclamation Does sizeof() operator work with QT Objects?

    if I ve an QPixmap Object holding a image file.Does sizeof() work with this object to determine the number of bytes taken by that picture when loaded in memory?
    Thank you in advance.

  2. #2
    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: Does sizeof() operator work with QT Objects?

    No. sizeof() returns size of the object, not its data.
    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.


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

    Default Re: Does sizeof() operator work with QT Objects?

    If you want to know the size of an image in bytes you load into a QImage and use its byteCount() method.

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    leebandemaha (7th September 2013)

  5. #4
    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: Does sizeof() operator work with QT Objects?

    Quote Originally Posted by anda_skoa View Post
    If you want to know the size of an image in bytes you load into a QImage and use its byteCount() method.
    However the size depends on the image format used and in most cases will be different than what size QPixmap occupies.
    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.


Similar Threads

  1. Dynamical objects (by operator new) in Qt
    By spherrra in forum Qt Programming
    Replies: 16
    Last Post: 10th October 2011, 20:06
  2. convert from QString to char[sizeof(...)]
    By adamatic in forum Qt Programming
    Replies: 4
    Last Post: 3rd September 2011, 09:05
  3. Sizeof wrong with structures ?????
    By tonnot in forum General Programming
    Replies: 11
    Last Post: 28th June 2011, 07:54
  4. Simple: Operator overloading with heap objects
    By durbrak in forum General Programming
    Replies: 12
    Last Post: 25th April 2007, 13:20
  5. which one is constant,sizeof(int) or sizeof(long)?
    By coralbird in forum Qt Programming
    Replies: 4
    Last Post: 20th March 2006, 11:01

Tags for this Thread

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.