Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User NMMA's Avatar
    Join Date
    Apr 2010
    Posts
    62
    I have struct contains following members:

    MyStruct
    {

    unsigned int x;
    float y;
    float z;

    unsigned short m;
    char ph_ n;
    char ph_ l;

    char ph_r;
    BYTE inf_id;
    BYTE index;
    BYTE len_;
    };

    I need to read data from my file and fill my struct like that
    MyStrucct* ms;

    ... Read(ms, size)
    Can I do that using QFile?

    any one can help me with example?

  2. #2
    Nokia Developer Champion danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    Have you looked at the reference? http://doc.qt.nokia.com/4.6-snapshot/qfile.html

    There are a few examples there.

    Remember that you have to check the inherited members by clicking on the link above the main listing of members in order to see some of the most important methods (such as read()).

  3. #3
    Registered User NMMA's Avatar
    Join Date
    Apr 2010
    Posts
    62
    I saw this kink... but I need example about how to fill struct...read function not take void*

  4. #4
    Nokia Developer Champion danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    I'd suggest you learn how to cast pointers then.

  5. #5
    Nokia Developer Moderator divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    Do you mean something like this?
    Code:
    QFile file("file.bin");
    if (!file.open(QIODevice::ReadOnly))
      return;
    
    MyStrucct ms;
    file.read((char*)&ms, sizeof(ms));
    file.close();

  6. #6
    Nokia Developer Champion danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    Something like that.

Similar Threads

  1. QFile problem
    By BalajiR in forum Qt
    Replies: 9
    Last Post: 2010-03-04, 05:49
  2. QFile::seek: IODevice is not open
    By rongyihit in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 0
    Last Post: 2009-08-18, 09:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved