2013-08-06 3 views
1

사용자가 응용 프로그램 아이콘을 클릭 할 때 시작 페이지를 표시하려고합니다. 이를 위해 시트를 만들고 페이지에 첨부했습니다. main.qml 작업 완료 후qml에서 시트를 닫는 방법?

import bb.cascades 1.0 

Page { 
    Container { 
     Label { 
      text: "Home page" 
      verticalAlignment: VerticalAlignment.Center 
      horizontalAlignment: HorizontalAlignment.Center 
     } 
    } 
    attachedObjects: [ 
     Sheet { 
      id: mySheet 
      content: Page { 
       Label { 
        text: "Splash Page/Sheet." 
       } 
      } 
     } 
    ]//end of attached objects 
    onCreationCompleted: { 

     //open the sheet 
     mySheet.open(); 

     //After that doing some task here. 
     --------- 
     --------- 
     --------- 

     //Now I'm closing the Sheet. But the Sheet was not closed. 
     //It is showing the Sheet/Splash Page only, not the Home Page 
     mySheet.close(); 
    } 
}//end of page 

, 나는 시트를 닫으려면. 그래서 close() 메서드를 호출했습니다.하지만 시트가 닫히지 않았습니다.

oncreationCompleted() 메서드 또는 C++ 메서드에서 시트를 닫으려면 어떻게해야합니까?

+0

당신이''mySheet.close() 후/이전 로그를 넣어하려고 했나, 당신이 그것에 도달해야 할,''? –

+0

예, 테스트 해본 결과 로그 메시지도 인쇄됩니다. – user2636874

+1

작업 시간은 얼마나됩니까? 시트를 닫으려고해도 시트가 완전히 열리지 않았을 수 있습니다 (애니메이션이 종료되지 않았을 수 있음). –

답변

1

개구부가 완료되기 전에 (애니메이션이 실행 중임) Sheet을 닫으려고하므로 닫는 요청이 무시됩니다. 애니메이션의 끝 (opened() 신호)을 모니터링해야 Sheet이 아직 열리지 않았는지 알 수 있습니다. 나는 그런 일을 할 것입니다 :

import bb.cascades 1.0 

Page { 
    Container { 
     Label { 
      text: "Home page" 
      verticalAlignment: VerticalAlignment.Center 
      horizontalAlignment: HorizontalAlignment.Center 
     } 
    } 
    attachedObjects: [ 
     Sheet { 
      id: mySheet 
      property finished bool: false 
      content: Page { 
       Label { 
        text: "Splash Page/Sheet." 
       } 
      } 
      // We request a close if the task is finished once the opening is complete 
      onOpened: { 
       if (finished) { 
        close(); 
       } 
      } 
     } 
    ]//end of attached objects 
    onCreationCompleted: { 

     //open the sheet 
     mySheet.open(); 

     //After that doing some task here. 
     --------- 
     --------- 
     --------- 

     //Now I'm closing the Sheet. But the Sheet was not closed. 
     //It is showing the Sheet/Splash Page only, not the Home Page 
     mySheet.finished = true; 
     // If the Sheet is opened, we close it 
     if (mySheet.opened) { 
      mySheet.close(); 
     } 
    } 
}//end of page
+0

일부 OS에서는이 신호가 보내지지 않습니다. QTimer를 사용하여 수동으로 닫으려면 "isOpened()"상태를 확인해야했습니다. – Benoit

+0

onOpened() 메서드에서 직접 시트를 닫는 대신 코드에서 언급 한대로 시도했습니다. 그런 다음 시트가 닫히지 않습니다. – user2636874

+0

console.log ("onOpened")를 추가하십시오. 이 슬롯이 호출되는지 확인하려면 – Benoit

관련 문제