Results 1 to 2 of 2

Thread: QML: a SwipeView inside a Rectangle

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default QML: a SwipeView inside a Rectangle

    I've been trying to place a SwipeView with two pages inside a Rectangle and indent it by 20 pixels from each side:

    Qt Code:
    1. import QtQuick 2.7
    2. import QtQuick.Controls 2.0
    3. import QtQuick.Layouts 1.0
    4.  
    5. ApplicationWindow
    6. {
    7. visible: true
    8. width: 640
    9. height: 480
    10. title: qsTr("Hello World")
    11.  
    12. Column
    13. {
    14. anchors.fill: parent
    15. //anchors.margins: 20
    16.  
    17. Rectangle
    18. {
    19. id: yellowRect
    20. color: "yellow"
    21. width: parent.width
    22. height: parent.height - tabBar.height
    23. //anchors.fill: parent
    24. //anchors.margins: 20
    25.  
    26. SwipeView
    27. {
    28. id: swipeView
    29. //parent: yellowRect
    30. //anchors.fill: yellowRect//parent
    31. anchors.margins: 20
    32. anchors.fill: parent
    33. currentIndex: tabBar.currentIndex
    34.  
    35. Page
    36. {
    37. //width: 300
    38. //height: 300
    39. //anchors.fill: parent
    40. //anchors.margins: 20
    41. Column
    42. {
    43. Label { text: "First page" }
    44. TextField { }
    45. }
    46. }
    47.  
    48. Page
    49. {
    50. //anchors.fill: parent
    51. //anchors.margins: 20
    52. //width: 300
    53. //height: 300
    54. Label {
    55. text: qsTr("Second page")
    56. anchors.centerIn: parent
    57. }
    58. }
    59. } // Swipeview
    60. } // Rectangle
    61.  
    62. TabBar
    63. {
    64. id: tabBar
    65. TabButton { text: "First" }
    66. TabButton { text: "Second" }
    67. }
    68. } // Column
    69. } // ApplicationWindow
    To copy to clipboard, switch view to plain text mode 

    The code above produces the following:
    Знімок екрана 2017-01-30 12.09.41.jpg
    Знімок екрана 2017-01-30 12.09.52.jpg

    In particular, there is no indent on the right when the first page is active or the left when the second page is active.

    How can I fix that?
    Magicians do not exist

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QML: a SwipeView inside a Rectangle

    That could be the pages being drawn outside the parent.

    You could check by enabling clipping on the parent/view.

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 19th December 2016, 17:12
  2. Replies: 1
    Last Post: 15th June 2016, 08:51
  3. Replies: 2
    Last Post: 25th December 2014, 15:15
  4. Replies: 0
    Last Post: 16th July 2012, 09:56
  5. Getting the bounding rectangle
    By ioannis in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2009, 00:41

Tags for this Thread

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.