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. Create page with header and footer
Forum Updated to NodeBB v4.3 + New Features

Create page with header and footer

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 739 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.
  • N Offline
    N Offline
    nroos
    wrote on 22 Aug 2023, 15:36 last edited by
    #1

    Hello,

    I have run out of ideas how i could create a simple page (template) with header, body and footer in QML. It should have a text as header, a user configurable body and another text as footer. I know there is a component which does exactly this, but i would like to do it manually for learning purposes.

    My intuitive approach would be a component like this:

    // Page.qml
    
    import QtQuick
    
    Column {
    	property alias body: compBody.data
    	property alias header: compHeader.text
    	property alias footer: compFooter.text
    
    	Component {
    		Column {
    			id: compBody
    		}
    	}
    
    	Component {
    		Text {
    			id: compHeader
    		}
    	}
    
    	Component {
    		Text {
    			id: compFooter
    		}
    	}
    
    	compHeader
    	compBody
    	compFooter
    }
    

    This doesn't compile but shows what i want to achieve. I tried several other attempts as well, but to no success.

    So what is an elegant way to get such a component working?

    J M 2 Replies Last reply 22 Aug 2023, 21:06
    0
    • N nroos
      22 Aug 2023, 15:36

      Hello,

      I have run out of ideas how i could create a simple page (template) with header, body and footer in QML. It should have a text as header, a user configurable body and another text as footer. I know there is a component which does exactly this, but i would like to do it manually for learning purposes.

      My intuitive approach would be a component like this:

      // Page.qml
      
      import QtQuick
      
      Column {
      	property alias body: compBody.data
      	property alias header: compHeader.text
      	property alias footer: compFooter.text
      
      	Component {
      		Column {
      			id: compBody
      		}
      	}
      
      	Component {
      		Text {
      			id: compHeader
      		}
      	}
      
      	Component {
      		Text {
      			id: compFooter
      		}
      	}
      
      	compHeader
      	compBody
      	compFooter
      }
      

      This doesn't compile but shows what i want to achieve. I tried several other attempts as well, but to no success.

      So what is an elegant way to get such a component working?

      M Offline
      M Offline
      mzimmers
      wrote on 22 Aug 2023, 21:41 last edited by
      #3

      @nroos well, IMO the "elegant" way to do it is to use the supplied QML type for this that @JoeCFD referenced.

      But if you want to do it yourself, I don't think you want/need to use the Component item. Just use a ColumnLayout and put whatever items you want in it to represent the header, body and footer areas.

      N 1 Reply Last reply 23 Aug 2023, 09:57
      0
      • N nroos
        22 Aug 2023, 15:36

        Hello,

        I have run out of ideas how i could create a simple page (template) with header, body and footer in QML. It should have a text as header, a user configurable body and another text as footer. I know there is a component which does exactly this, but i would like to do it manually for learning purposes.

        My intuitive approach would be a component like this:

        // Page.qml
        
        import QtQuick
        
        Column {
        	property alias body: compBody.data
        	property alias header: compHeader.text
        	property alias footer: compFooter.text
        
        	Component {
        		Column {
        			id: compBody
        		}
        	}
        
        	Component {
        		Text {
        			id: compHeader
        		}
        	}
        
        	Component {
        		Text {
        			id: compFooter
        		}
        	}
        
        	compHeader
        	compBody
        	compFooter
        }
        

        This doesn't compile but shows what i want to achieve. I tried several other attempts as well, but to no success.

        So what is an elegant way to get such a component working?

        J Offline
        J Offline
        JoeCFD
        wrote on 22 Aug 2023, 21:06 last edited by
        #2

        @nroos
        is this what you want?
        https://doc.qt.io/qt-6/qml-qtquick-controls-page.html

        1 Reply Last reply
        0
        • N nroos
          22 Aug 2023, 15:36

          Hello,

          I have run out of ideas how i could create a simple page (template) with header, body and footer in QML. It should have a text as header, a user configurable body and another text as footer. I know there is a component which does exactly this, but i would like to do it manually for learning purposes.

          My intuitive approach would be a component like this:

          // Page.qml
          
          import QtQuick
          
          Column {
          	property alias body: compBody.data
          	property alias header: compHeader.text
          	property alias footer: compFooter.text
          
          	Component {
          		Column {
          			id: compBody
          		}
          	}
          
          	Component {
          		Text {
          			id: compHeader
          		}
          	}
          
          	Component {
          		Text {
          			id: compFooter
          		}
          	}
          
          	compHeader
          	compBody
          	compFooter
          }
          

          This doesn't compile but shows what i want to achieve. I tried several other attempts as well, but to no success.

          So what is an elegant way to get such a component working?

          M Offline
          M Offline
          mzimmers
          wrote on 22 Aug 2023, 21:41 last edited by
          #3

          @nroos well, IMO the "elegant" way to do it is to use the supplied QML type for this that @JoeCFD referenced.

          But if you want to do it yourself, I don't think you want/need to use the Component item. Just use a ColumnLayout and put whatever items you want in it to represent the header, body and footer areas.

          N 1 Reply Last reply 23 Aug 2023, 09:57
          0
          • M mzimmers
            22 Aug 2023, 21:41

            @nroos well, IMO the "elegant" way to do it is to use the supplied QML type for this that @JoeCFD referenced.

            But if you want to do it yourself, I don't think you want/need to use the Component item. Just use a ColumnLayout and put whatever items you want in it to represent the header, body and footer areas.

            N Offline
            N Offline
            nroos
            wrote on 23 Aug 2023, 09:57 last edited by
            #4

            @mzimmers said in Create page with header and footer:

            But if you want to do it yourself, I don't think you want/need to use the Component item. Just use a ColumnLayout and put whatever items you want in it to represent the header, body and footer areas.

            Strange, i nearly had it but didn't come to this simple solution. Anyway, this helped me further, it's working now, thank you!

            1 Reply Last reply
            0
            • N nroos has marked this topic as solved on 23 Aug 2023, 09:57

            1/4

            22 Aug 2023, 15:36

            • Login

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