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
Qt 6.11 is out! See what's new in the release blog

Create page with header and footer

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 1.1k 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 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?

    JoeCFDJ mzimmersM 2 Replies Last reply
    0
    • N nroos

      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?

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on 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
      0
      • N nroos

        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?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on 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

          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?

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on 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
          0
          • mzimmersM mzimmers

            @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 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

            • Login

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