Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Alignment boundary issue
Forum Updated to NodeBB v4.3 + New Features

Alignment boundary issue

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 4.4k Views
  • 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.
  • AlienA Offline
    AlienA Offline
    Alien
    wrote on last edited by
    #1

    Hi,

    I define a class something like below :

    class LayerInformation
    {
    public:
        LayerInformation();
        LayerInformation(QString *name,bool *isVisible,QString *dateOfCreation,QString *description);
    
        QString name() const;
    
        bool isVisible() const;
    
        QString date_of_creation() const;
    
        QString description() const;
    
        void setName(const QString &name);
    
        void setIsVisible(bool isVisible);
    
        void setDate_of_creation(const QString &date_of_creation);
    
        void setDescription(const QString &description);
    
    private:
        QString m_name;
        QString m_date_of_creation;
        QString m_description;
        bool m_isVisible;
    };
    Q_DECLARE_METATYPE(LayerInformation)
    

    but the compiler complain about padding size:
    "Padding size of LayerInformation with 3 bytes to alignment boundary"
    It's warning not an error but I want to fix this and I don't know why I face to this message!?

    E 1 Reply Last reply
    0
    • AlienA Alien

      @Eeli-K ,
      So how to solve this?

      AlienA Offline
      AlienA Offline
      Alien
      wrote on last edited by
      #6

      @Alien ,
      It can solve by adding 3 bytes in the private variable something like:
      char m_padding[3];
      or use #pragma pack(1) instead(It can cause performance issues).

      1 Reply Last reply
      0
      • AlienA Alien

        Hi,

        I define a class something like below :

        class LayerInformation
        {
        public:
            LayerInformation();
            LayerInformation(QString *name,bool *isVisible,QString *dateOfCreation,QString *description);
        
            QString name() const;
        
            bool isVisible() const;
        
            QString date_of_creation() const;
        
            QString description() const;
        
            void setName(const QString &name);
        
            void setIsVisible(bool isVisible);
        
            void setDate_of_creation(const QString &date_of_creation);
        
            void setDescription(const QString &description);
        
        private:
            QString m_name;
            QString m_date_of_creation;
            QString m_description;
            bool m_isVisible;
        };
        Q_DECLARE_METATYPE(LayerInformation)
        

        but the compiler complain about padding size:
        "Padding size of LayerInformation with 3 bytes to alignment boundary"
        It's warning not an error but I want to fix this and I don't know why I face to this message!?

        E Offline
        E Offline
        Eeli K
        wrote on last edited by
        #2

        @Alien Tell us more about your development environment, OS, compiler name and version. This is quite certainly compiler dependent. And it's always recommended to copypaste the exact message lines and some context.

        AlienA 1 Reply Last reply
        0
        • E Eeli K

          @Alien Tell us more about your development environment, OS, compiler name and version. This is quite certainly compiler dependent. And it's always recommended to copypaste the exact message lines and some context.

          AlienA Offline
          AlienA Offline
          Alien
          wrote on last edited by
          #3

          @Eeli-K ,
          sorry
          OS:Windows 7 x64
          QT SDK: 5.8.0 MinGW 32bit
          And I want to use this in Qt Quick
          Thanks,

          E 1 Reply Last reply
          0
          • AlienA Alien

            @Eeli-K ,
            sorry
            OS:Windows 7 x64
            QT SDK: 5.8.0 MinGW 32bit
            And I want to use this in Qt Quick
            Thanks,

            E Offline
            E Offline
            Eeli K
            wrote on last edited by
            #4

            @Alien See if this helps: http://stackoverflow.com/questions/20184259/what-does-the-padding-class-tester-with-4-bytes-warning-mean

            AlienA 1 Reply Last reply
            1
            • E Eeli K

              @Alien See if this helps: http://stackoverflow.com/questions/20184259/what-does-the-padding-class-tester-with-4-bytes-warning-mean

              AlienA Offline
              AlienA Offline
              Alien
              wrote on last edited by
              #5

              @Eeli-K ,
              So how to solve this?

              AlienA 1 Reply Last reply
              0
              • AlienA Alien

                @Eeli-K ,
                So how to solve this?

                AlienA Offline
                AlienA Offline
                Alien
                wrote on last edited by
                #6

                @Alien ,
                It can solve by adding 3 bytes in the private variable something like:
                char m_padding[3];
                or use #pragma pack(1) instead(It can cause performance issues).

                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