Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFile design
Forum Updated to NodeBB v4.3 + New Features

QFile design

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redlars
    wrote on last edited by
    #1

    Using Qt 4.7.1

    Looking at the QFile implementation it appears that all member variables are stored in a class QFilePrivate which does not provide any form of encapsulation.

    What benefit does the separation of methods and variables provide? Is this a design pattern?

    To access the instance of QFilePrivate the QFile uses the "d" pointer. An example "d->fileName.IsEmpty()". Where is the pointer "d" defined?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on last edited by
      #2

      It is mostly the case in Qt framework with private classes. It is just to make end class look pretty for developers. pointer *d is always defined in private section of its end class. The private class itself is predefined in header, right before end class.
      @class QFilePrivate;@
      and declared in .cpp file.
      or just in separate private header and source files which you can find under src/ folder and not in include/ folder.

      It is actually nice design pattern, helps make code clear in big projects and hide simple and conventional code which will mostly never changed in separate classes...

      God is Real unless explicitly declared as Integer.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        "What is the d-pointer":http://qt-project.org/wiki/Dpointer

        1 Reply Last reply
        0
        • R Offline
          R Offline
          redlars
          wrote on last edited by
          #4

          Thought "this":http://zchydem.enume.net/2010/01/19/qt-howto-private-classes-and-d-pointers/ and "this":http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Definition article described the issue nicely.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            Actually, it provides very strong encapsulation. You cannot access the d pointer as a user of the API, which is the whole point of encapsulation.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved