Facebook
From pwl, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 112
  1. import QtQuick 2.12
  2. import QtQuick.Window 2.12
  3. import QtQuick.Controls 2.14
  4. import io.qt.MainWindow 1.0
  5.  
  6.  
  7. Window {
  8.     visible: true
  9.     width: 1080
  10.     height: 720
  11.     title: qsTr("Hello World")
  12.  
  13.     MainWindow{
  14.         id: mainWindow
  15.         onMoveCircle: {
  16.             print("received")
  17.             view.currentIndex= index;
  18.         }
  19.     }
  20.  
  21.     Component {
  22.         id: appDelegate
  23.         Item {
  24.             width: 100; height: 100
  25.             scale: PathView.iconScale
  26.  
  27.             Image {
  28.                 id: myIcon
  29.                 y: 20; anchors.horizontalCenter: parent.horizontalCenter
  30.                 source: icon
  31.             }
  32.             Text {
  33.                 anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter }
  34.                 text: name
  35.             }
  36.  
  37.             MouseArea {
  38.                 anchors.fill: parent
  39.                 onClicked: view.currentIndex = index
  40.             }
  41.         }
  42.     }
  43.  
  44.     ListModel {
  45.         id: appModel
  46.         ListElement { name: "Music"; icon: "pics/elem_1.png" }
  47.         ListElement { name: "Movies"; icon: "pics/elem_2.png" }
  48.         ListElement { name: "Camera"; icon: "pics/elem_3.png" }
  49.         ListElement { name: "Calendar"; icon: "pics/elem_4.png" }
  50.         ListElement { name: "Messaging"; icon: "pics/elem_5.png" }
  51.         ListElement { name: "Todo List"; icon: "pics/elem_6.png" }
  52.     }
  53.  
  54.     PathView {
  55.         id: view
  56.         anchors.fill: parent
  57.         anchors.bottomMargin: 150
  58.         anchors.topMargin: 50
  59.         pathItemCount: 7
  60.         preferredHighlightBegin: 0.5
  61.         preferredHighlightEnd: 0.5
  62.         highlightRangeMode: PathView.StrictlyEnforceRange
  63.         model: appModel
  64.         delegate: appDelegate
  65.         path: Path {
  66.             startX: 0; startY: view.height/2
  67.             PathAttribute { name: "iconScale"; value: 0.2 }
  68.             PathAttribute { name: "iconOpacity"; value: 10.2 }
  69.             PathAttribute { name: "iconOrder"; value: 0 }
  70.             PathLine {x: view.width / 2; y: view.height/2 }
  71.             PathAttribute { name: "iconScale"; value: 1.2 }
  72.             PathAttribute { name: "iconOpacity"; value: 1 }
  73.             PathAttribute { name: "iconOrder"; value: 8 }
  74.             PathLine {x: view.width; y: view.height/2 }
  75.         }
  76.  
  77.     }
  78.  
  79.     Button{
  80.         id:draw
  81.         width: 50
  82.         height: 50
  83.         x: parent.width/2-width/2
  84.         y: parent.height*0.8-height
  85.         onClicked: {
  86.             mainWindow.rotate()
  87.         }
  88.     }
  89. }
  90.  
  91.  
  92.  
  93. SLOT z CPP
  94.  
  95. void MainWindow::rotate(){
  96.  
  97.     for(int i=0; i< 5; i++){
  98.             QThread::msleep(1000);
  99.         emit moveCircle(idx);
  100.         idx++;
  101.     }
  102. }
  103.    /* for(int i=0; i< 5; i++){
  104.         QThread::msleep(500);
  105.         qDebug()<<"emit";
  106.         emit moveCircle(i);
  107.         }
  108. }*/
  109.