Results 1 to 8 of 8

Thread: Application freezes when using ColumnLayout in a view loaded by a loader

  1. #1
    Join Date
    Dec 2015
    Location
    Austria
    Posts
    23
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: Application freezes when using ColumnLayout in a view loaded by a loader

    Hi

    I have a Problem with any type of Layout Control in a "subView"
    If i load following qml into a Loader Object which is present in the main.qml
    The app stucks and doesnt react any more. I dont know what i am doing wrong
    If i remove the ColumnLayou from the view.qml it works.
    If use the columnLayout in the main.qml it works without any Problem.

    viewQml
    Qt Code:
    1. import QtQuick 2.5
    2. import QtQuick.Layouts 1.2
    3.  
    4.  
    5. Rectangle {
    6. color: guiTheme.view.backgroundColor
    7. anchors.fill: parent
    8.  
    9. ColumnLayout
    10. {
    11. anchors.fill: parent
    12. spacing : 0
    13.  
    14.  
    15. Text {
    16.  
    17. anchors.top: parent.top
    18. anchors.topMargin: 20
    19. anchors.left: parent.left
    20. anchors.leftMargin: 20
    21. anchors.right: parent.right
    22. anchors.rightMargin: 20
    23.  
    24. horizontalAlignment: Text.AlignJustify
    25. wrapMode: Text.Wrap
    26.  
    27. text: qsTr("Test")
    28.  
    29. color: guiTheme.view.standardTextColor
    30. font.pixelSize: guiTheme.app.standardTextSize
    31. font.family: guiTheme.app.fontFamily
    32. }
    33.  
    34.  
    35. }
    36.  
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 

    Main.qml
    Qt Code:
    1. import QtQuick 2.5
    2. import QtQuick.Controls 1.4
    3. import QtQuick.Window 2.0
    4.  
    5. ApplicationWindow {
    6.  
    7. Loader {
    8. id: loaderViewContainer
    9. anchors.fill: parent
    10. focus: true
    11. source: viewControllerObject.currentQmlViewPath / contains above qml
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    The main qml is loaded with the QQmlApplicationEngine.load(...)

    Any suggestions?
    THANKS!


    Added after 21 minutes:


    Okay....
    The Problem is this code
    Qt Code:
    1. anchors.right: parent.right
    2. anchors.rightMargin: 20
    3.  
    4. wrapMode: Text.Wrap
    To copy to clipboard, switch view to plain text mode 
    Wehn i am removing the wrapMode it works....?!?!
    Of course this will lokk bad if i have Long text...
    Last edited by ChriD; 23rd January 2016 at 12:26.

  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: Application freezes when using ColumnLayout in a view loaded by a loader

    Using anchors in a child of a column layout is almost certainly wrong, after all it is the main purpose of the layout to arrange its children.
    This should actually have triggered a warning on the application's console output.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    ChriD (23rd January 2016)

  4. #3
    Join Date
    Dec 2015
    Location
    Austria
    Posts
    23
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: Application freezes when using ColumnLayout in a view loaded by a loader

    Okay.. i found a Solution
    I added a rectangle as a parent to the text and create the anchors there
    Qt Code:
    1. Rectangle
    2. {
    3. anchors.top: parent.top
    4. anchors.topMargin: 20
    5. anchors.left: parent.left
    6. anchors.leftMargin: 20
    7. anchors.right: parent.right
    8. anchors.rightMargin: 20
    9.  
    10. Text {
    11.  
    12. width: parent.width
    13.  
    14. horizontalAlignment: Text.AlignJustify
    15. wrapMode: Text.Wrap
    16. text: qsTr("Bitte wählen sie hier das System mit dem sie die Applikation verbinden wollen")
    17.  
    18. color: guiTheme.view.standardTextColor
    19. font.pixelSize: guiTheme.app.standardTextSize
    20. font.family: guiTheme.app.fontFamily
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 


    Added after 4 minutes:


    Addd.. didnt se your answer before my post @anda_skoa
    So i shouldnt Event anchors rectangles in the column Layout and should use
    Qt Code:
    1. Layout.alignment: Qt.AlignCenter
    2. Layout.preferredWidth: 40
    3. Layout.preferredHeight: 40
    To copy to clipboard, switch view to plain text mode 
    ?
    Last edited by ChriD; 23rd January 2016 at 12:34.

  5. #4
    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: Application freezes when using ColumnLayout in a view loaded by a loader

    Quote Originally Posted by ChriD View Post
    So i shouldnt Event anchors rectangles in the column Layout and should use
    Qt Code:
    1. Layout.alignment: Qt.AlignCenter
    2. Layout.preferredWidth: 40
    3. Layout.preferredHeight: 40
    To copy to clipboard, switch view to plain text mode 
    ?
    Yes. Using anchors inside a layout or positioner makes not sense at all.

    In fact it will create conflicting positioning and sizing hooks.

    Cheers,
    _

  6. #5
    Join Date
    Dec 2015
    Location
    Austria
    Posts
    23
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: Application freezes when using ColumnLayout in a view loaded by a loader

    Okay i understand.
    But im having big Troubles using the ColumnLayout with a Text with word wraps. If i do not define any height for the text (i dont know the height of course)
    The documentation of the layouts is always with fixed height...

    Maybe you can give me a short example how to use the ColumnLayout to have the 3 textControls with word wrap?
    I dont get the Point with the dynamic height of the text controls.


    Added after 10 minutes:


    At least i can do it with Column Object and by Setting the height of the parent rectangle of the text by usinf testId.height
    But i think this is no good solution

    Qt Code:
    1. Column
    2. {
    3. spacing: 2
    4.  
    5. anchors.fill: parent
    6. anchors.topMargin: 20
    7. anchors.leftMargin: 20
    8. anchors.rightMargin: 20
    9.  
    10. Rectangle
    11. {
    12. height: textId.height
    13. width: parent.width
    14. color: "green"
    15.  
    16. Text {
    17. id: textId
    18. width: parent.width
    19.  
    20. horizontalAlignment: Text.AlignJustify
    21. wrapMode: Text.Wrap
    22. text: qsTr("Bitte wählen sie hier das System mit dem sie die Applikation verbinden wollen")
    23.  
    24. color: guiTheme.view.standardTextColor
    25. font.pixelSize: guiTheme.app.standardTextSize
    26. font.family: guiTheme.app.fontFamily
    27. }
    28. }
    29.  
    30.  
    31. Rectangle
    32. {
    33. height: textId2.height
    34. width: parent.width
    35. color: "blue"
    36.  
    37. Text {
    38.  
    39. width: parent.width
    40. id: textId2
    41. horizontalAlignment: Text.AlignJustify
    42. wrapMode: Text.Wrap
    43. text: qsTr("lorem ipsum test 2 test 3 test 4 lorem ipsum holla die waldfee")
    44. }
    45. }
    46. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by ChriD; 23rd January 2016 at 13:34.

  7. #6
    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: Application freezes when using ColumnLayout in a view loaded by a loader

    I am not sure I understand, this looks fine.
    You are using these rectangles to have some background color behind the text elements?

    Cheers,
    _

  8. #7
    Join Date
    Dec 2015
    Location
    Austria
    Posts
    23
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: Application freezes when using ColumnLayout in a view loaded by a loader

    In fact i don't need the rectangles. I'm only playing around how all gets together and how it behaves
    If i remove the rectangles the 2 texts will be shown as i expected
    If i keep the rectangles and i do not provide any height to them, the texts will overlapp on the same Position.

    First i found that a Little bit confusing but now i think i get the point.
    Of course the rectangle will not automatically set its height to its children. There are only a view objects like column, row, flow, grid,... that will do so.

    Thank you for your help!

  9. #8
    Join Date
    Dec 2015
    Posts
    5
    Thanked 1 Time in 1 Post

    Default Re: Application freezes when using ColumnLayout in a view loaded by a loader

    Use Item instead of Rectangle.

Similar Threads

  1. Replies: 1
    Last Post: 15th September 2015, 09:22
  2. Replies: 0
    Last Post: 27th November 2014, 10:24
  3. Replies: 4
    Last Post: 30th October 2014, 09:19
  4. Application freezes for 0.5 sec after keyPressEvent
    By Coolcat in forum Qt Programming
    Replies: 1
    Last Post: 21st April 2011, 12:16
  5. My SDI application freezes when it is inactive ...why ?
    By yellowmat in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2006, 16:37

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.