Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

MultiplayerDemo

 import QtQuick 2.0
 import QtQuick.Controls 1.3

 // a console showing the actions of the players in text form
 Item {
   id: sconsole

   // the background of the console
   Rectangle {
     anchors.fill: parent
     color: "black"
     opacity: 0.5
   }

   // the flickable and scrollable content of the console
   ScrollView {
     id: scrollView
     anchors.fill: parent
     anchors.margins: 6

     // the text within the console
     Text {
       id: text
       color: "white"
       font.pixelSize: 8
       text: ""
     }

     // scrolls to the bottom of the text everytime the content changes
     function scrollToBottom() {
       var rawOffset = scrollView.flickableItem.contentHeight - scrollView.height;
       var correctedOffset = rawOffset >= 0 ? rawOffset: 0;
       scrollView.flickableItem.contentY = correctedOffset;
     }
   }

   // add a line to the text within the console
   function printLn(string) {
     // unless this is the first line, add a newline
     if (text.text.length > 0) {
       text.text += "\n";
     }

     // add our string
     text.text += string;
     scrollView.scrollToBottom();
   }

   // clear the console by deleting the text
   function clear() {
     text.text = "";
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded