Results 1 to 2 of 2

Thread: Interface using by QML pageStack ??

  1. #1
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Interface using by QML pageStack ??

    Hello, I have got a problem. I was trying to create interface using qml with c++ code I have connection between c++ and qml but when I want change a window when somebody push a button in qml interface I have a problem. How to change a qml files in interface is it possible ? Now I'm trying to use a pageStack but it is need to use symbian module is it necessary ? Can you put any examples?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Interface using by QML pageStack ??

    This is the simplest solution I can think of:
    javascript Code:
    1. // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    2. import QtQuick 1.1
    3.  
    4. Rectangle {
    5. width: 360
    6. height: 360
    7. Rectangle {
    8. id: stack
    9. property Item currentPage
    10.  
    11. anchors.left: parent.left
    12. anchors.right: parent.right
    13. anchors.top: parent.top
    14. height: 300
    15.  
    16. function push(objId) {
    17. if(currentPage !== null)
    18. currentPage.opacity = 0
    19. currentPage = objId
    20. objId.opacity = 1
    21. }
    22.  
    23. Rectangle {
    24. opacity: 0
    25. id: page1
    26. color: "red"
    27. anchors.fill: stack
    28. Behavior on opacity { NumberAnimation {}}
    29. }
    30. Rectangle {
    31. opacity: 0
    32. id: page2
    33. color: "blue"
    34. anchors.fill: stack
    35. Behavior on opacity { NumberAnimation {}}
    36. }
    37. }
    38.  
    39. Row {
    40. anchors.bottom: parent.bottom
    41. anchors.top: stack.bottom
    42. anchors.left: parent.left
    43. anchors.right: parent.right
    44. spacing: 5
    45.  
    46. Button {
    47. text: "one"
    48. onClicked: stack.push(page1)
    49.  
    50. }
    51. Button {
    52. text: "two"
    53. onClicked: stack.push(page2)
    54. }
    55. }
    56. }
    To copy to clipboard, switch view to plain text mode 

    Button.qml:
    javascript Code:
    1. // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    2. import QtQuick 1.1
    3.  
    4. Rectangle {
    5. id: root
    6. property string text
    7. property int textSize: 12
    8. property color textColor: "white"
    9. width: txt.width+10
    10. height: txt.height+5
    11. color: "#555"
    12.  
    13. signal clicked()
    14.  
    15. MouseArea {
    16. onClicked: root.clicked()
    17. anchors.fill: parent
    18. }
    19. Text {
    20. id: txt
    21. text: root.text
    22. anchors.centerIn: parent
    23. font.pointSize: textSize
    24. color: textColor
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

    It is not as functional as a real stack but it should get you started.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 12th August 2012, 17:37
  2. problem with interface Class - Error:undefined interface
    By k.qasempour in forum Qt Programming
    Replies: 4
    Last Post: 12th August 2012, 02:11
  3. use pagestack.pop(page,immediate)
    By jindoniit in forum Qt Quick
    Replies: 0
    Last Post: 20th October 2011, 03:08
  4. memory increase when use PageStack
    By jindoniit in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 13th October 2011, 11:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.