Results 1 to 2 of 2

Thread: Force re-creation of a QML object

  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Force re-creation of a QML object

    Hi,
    is it possible to force the re-creation of a QML item (here: TableView)?

    For a TableView (QuickControls 1.4), I use the resource property in the way shown below (shortened).

    When I want to change the content of a header, this is not being updated/displayed. Of course, my model emits:
    Qt Code:
    1. emit this->headerDataChanged(Qt::Horizontal,0,999);
    To copy to clipboard, switch view to plain text mode 

    I have tried binding in line 18 of the biggest code block :
    Qt Code:
    1. "title": Qt.binding(function() { return tableModel.columnHeaderName(role) }),
    To copy to clipboard, switch view to plain text mode 
    Unfortunately, "role" is always the highest number, not the respective appropriate one.

    Calling update() does not help, toggling the visible property neither, even setting the model to undefined and back.
    Can I trigger the creation process somehow? Or is there a different way to force it into diplaying a header change after creation?

    Any help appreciated!
    Cheers,
    Sebastian

    This is the (partial) code:
    Qt Code:
    1. resources: {
    2. var roleList = tableModel ? tableModel.userRoleNames : 0
    3. var temp = []
    4. var columnComponent
    5.  
    6. for(var i=0; i<roleList.length; i++) {
    7. var role = roleList[i]
    8. (!tableModel.isColumnHidden(role)) {
    9. if
    10. var columnHeaderName = tableModel.columnHeaderName(role)
    11. if (tableModel.columnTypeName(role) === "QDate") {
    12. columnComponent = columnComponentDate;
    13. }
    14. if (columnComponent) {
    15. temp.push(columnComponent.createObject(
    16. dynamicTableViewBasis, {
    17. "role": role,
    18. "title": columnHeaderName,
    19. "width": tableModel.columnInitialWidth(role)
    20. }))
    21. }
    22. }
    23. }
    24. return temp
    25. }
    To copy to clipboard, switch view to plain text mode 

    As actual columns, I use components like this one:


    Qt Code:
    1. Component {
    2. id: columnComponentDate
    3. QQC14.TableViewColumn {
    4. delegate: Text {
    5. id: dateDelegate
    6. property date dateVar: styleData.value ? styleData.value : ""
    7. text: dateVar ? appController.dateStringShort(dateVar) : ""
    8. }
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    --
    http://www.classintouch.de - Tablet-Software für Lehrer
    Last edited by sedi; 27th October 2017 at 21:40. Reason: Forgot title...

  2. #2
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Force re-creation of a QML object

    The solution for me: putting the stuff in a loader. When I want to recreate the table, I just set the loader's source to "" and back.

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.