Results 1 to 2 of 2

Thread: Weird behavior when switching the view between Image and Camera

  1. #1
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Weird behavior when switching the view between Image and Camera

    Trying to switch the view between camera and image, but the results are pretty weird

    toolBarTest.qml
    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. Item{
    4. id:root
    5. height: 800; width: 144
    6.  
    7. signal fullScreen()
    8. signal camera()
    9. signal photo()
    10.  
    11. Column{
    12. id: toolBarColumn
    13.  
    14. anchors.fill: root
    15. spacing: 10
    16.  
    17. Rectangle{
    18.  
    19. width: 144
    20. height: 70
    21. color: "blue"
    22.  
    23. Text{
    24. text: "fullScreen"
    25. }
    26.  
    27. MouseArea{
    28. anchors.fill: parent
    29.  
    30. onClicked: {
    31. fullScreen()
    32. }
    33. }
    34. }
    35.  
    36. Rectangle{
    37.  
    38. width: 144
    39. height: 70
    40. color: "blue"
    41.  
    42. Text{
    43. text: "camera"
    44. }
    45.  
    46. MouseArea{
    47. anchors.fill: parent
    48.  
    49. onClicked: {
    50. camera()
    51. }
    52. }
    53. }
    54.  
    55. Rectangle{
    56.  
    57. width: 144
    58. height: 70
    59. color: "blue"
    60.  
    61. Text{
    62. text: "photo"
    63. }
    64.  
    65. MouseArea{
    66. anchors.fill: parent
    67.  
    68. onClicked: {
    69. photo()
    70. }
    71. }
    72. }
    73. }
    74. }
    To copy to clipboard, switch view to plain text mode 

    photoTest.qml
    Qt Code:
    1. import QtQuick 2.0
    2. import QtMultimedia 5.0
    3.  
    4.  
    5. Rectangle{
    6. id: root
    7.  
    8. width: 480
    9. height: 320
    10. color: "black"
    11. state: "PHOTO"
    12.  
    13. property alias source: largeImage.source
    14.  
    15. property var theID: largeImage
    16.  
    17. QtObject{
    18. id: param
    19.  
    20. property var theID: largeImage
    21. }
    22.  
    23. Image{
    24. id : largeImage
    25. anchors.fill: parent
    26. cache: false
    27. fillMode: Image.PreserveAspectFit
    28. smooth: true
    29. }
    30.  
    31. Camera{
    32. id: camera
    33. }
    34.  
    35. VideoOutput {
    36. id: videoOutput
    37.  
    38. anchors.fill: parent
    39. source: camera
    40. }
    41.  
    42. states:[
    43. State {
    44. name: "PHOTO"
    45. StateChangeScript{
    46. script:{
    47. camera.stop()
    48. param.theID = largeImage
    49. }
    50. }
    51.  
    52. PropertyChanges { target: largeImage; opacity: 1}
    53. PropertyChanges { target: videoOutput; opacity: 0}
    54. },
    55. State {
    56. name: "CAMERA"
    57. StateChangeScript{
    58. script:{
    59. camera.captureMode = Camera.CaptureStillImage
    60. camera.start()
    61. param.theID = videoOutput
    62. }
    63. }
    64.  
    65. PropertyChanges {target: largeImage; opacity: 0}
    66. PropertyChanges { target: videoOutput; opacity: 1}
    67. }
    68. ]
    69. }
    To copy to clipboard, switch view to plain text mode 

    main.qml
    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. Rectangle {
    4. id: root
    5.  
    6. width: 800
    7. height: 480
    8.  
    9. QtObject{
    10. id: param
    11.  
    12. property string previousFullScreenState
    13. }
    14.  
    15. ToolBarTest{
    16. id: toolBarTest
    17.  
    18. onFullScreen: {
    19. param.previousFullScreenState = root.state
    20. root.state = "FULLSCREEN"
    21. }
    22.  
    23. onPhoto: {
    24. root.state = "PHOTO"
    25. }
    26.  
    27. onCamera: {
    28. root.state = "CAMERA"
    29. }
    30. }
    31.  
    32. PhotoTest{
    33. id: photoTest
    34.  
    35. anchors.left: toolBarTest.right
    36. width: parent.width - toolBarTest.width
    37.  
    38. source: "/Users/yyyy/Downloads/1359170070532.jpg"
    39.  
    40. MouseArea{
    41. anchors.fill: parent
    42.  
    43. onClicked: {
    44. if(root.state == "FULLSCREEN"){
    45. root.state = param.previousFullScreenState
    46. }
    47. }
    48. }
    49. }
    50.  
    51. states: [
    52. State {
    53. name: "PHOTO"
    54.  
    55. PropertyChanges { target: photoTest; state: "PHOTO"}
    56. PropertyChanges { target: toolBarTest; width: 144}
    57. },
    58. State {
    59. name: "CAMERA"
    60.  
    61. PropertyChanges { target: photoTest; state: "CAMERA"}
    62. PropertyChanges { target: toolBarTest; width: 144}
    63. },
    64. State {
    65. name: "FULLSCREEN"
    66.  
    67. PropertyChanges { target: toolBarTest; width: 0}
    68. }
    69. ]
    70. }
    To copy to clipboard, switch view to plain text mode 

    Once the state is "CAMERA" and I click on the "fullScreen" button
    The photoTest.qml do not show me the fullsize of the camera but
    the fullsize of the photo, what is happening?What kind of error do I make?

    Qt version : 5.1Beta
    os : mac osx 10.8.3
    compiler: clang 3.2

  2. #2
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Weird behavior when switching the view between Image and Camera

    I explicit specified the state of "FULLSCREEN" in main.qml as

    Qt Code:
    1. State {
    2. name: "FULLSCREEN"
    3.  
    4. PropertyChanges { target: photoTest; state: param.fullScreenPreviousState == "PHOTO" ? "PHOTO" : "CAMERA"} //new conditon
    5. PropertyChanges { target: toolBarTest; width: 0}
    6. }
    To copy to clipboard, switch view to plain text mode 

    We have to explicit specify all of the conditions of different components when changing state?

Similar Threads

  1. ifstream failing, weird behavior
    By BettaUseYoNikes in forum Qt Programming
    Replies: 3
    Last Post: 25th August 2011, 00:17
  2. QWebView weird behavior !!
    By gontham in forum Newbie
    Replies: 1
    Last Post: 21st October 2010, 15:00
  3. Weird behavior under Ubuntu Gnome
    By psih128 in forum Qt Programming
    Replies: 0
    Last Post: 6th July 2010, 15:26
  4. Weird removeRow behavior
    By metalinspired in forum Qt Programming
    Replies: 0
    Last Post: 30th August 2009, 13:42
  5. Weird QMenu behavior on Mac
    By munna in forum Qt Programming
    Replies: 1
    Last Post: 14th January 2009, 16:18

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.