Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. model view prog
    Log in to post

    • SOLVED How to catch c++ model signals in qml&
      QML and Qt Quick • animations model view prog c++ model model signals • • T_e_d_d_y  

      4
      0
      Votes
      4
      Posts
      180
      Views

      @T_e_d_d_y nice, Actually you don't even need the Connections object model:GameBoardModel{ onPlacementChanged : {} }
    • UNSOLVED Inconsistency between model and view while updating QSqlTableModel cell
      QML and Qt Quick • qml model-view modelview model view prog • • Ahti  

      9
      0
      Votes
      9
      Posts
      329
      Views

      Did you saw the third argument of the signal ? The one you are currently not using in the code you provided. It's the one containing the custom roles.
    • UNSOLVED Accessing and altering the same view from different Qml files
      QML and Qt Quick • qml model-view model view prog • • Ahti  

      2
      0
      Votes
      2
      Posts
      346
      Views

      You can get StackView instance from Profile.qml quite easy, using StackView attached properties. Define new property at your StackView: StackView { id: home property var modeldata: null // Define StackView property initialItem: Pane { ... ListView { ... delegate: SwipeDelegate { ... swipe.onCompleted: { if (swipe.position > 0) { home.modeldata = model; // Set StackView property home.pop(); home.push("Profile.qml"); } ... } ... } } } } And then at Profile.qml you can easily get attached StackView property: Pane { id: profile ... Button { ... text: "Delete" onClicked: { let modeldata = profile.StackView.view.modeldata; // Accessing StackView property via attached properties if (modeldata !== null) { user_model.removeRow(modledata.index); } ... } } } In this case you do not need workaround with helper row. Also if you need some objects like your helper - better way is to use QtObject rather than visual 'invisible' object.
    • UNSOLVED Inconsistency between model and view while removing a row from a table.
      QML and Qt Quick • qml modelview model view prog • • Ahti  

      2
      0
      Votes
      2
      Posts
      82
      Views

      @Ahti Perhaps not relevant, but can't help noticing: your removeRows and its call to beginRemoveRows() correctly allows for multiple rows, but your call to response = model->removeRow(first, QModelIndex()); only allows for one row. That's works for your del_row(), but not in general. I don't suppose fixing that changes behaviour?
    • UNSOLVED Inconsistency between model and view after removing a row from a table
      QML and Qt Quick • qml model-view model view prog • • Ahti  

      2
      0
      Votes
      2
      Posts
      104
      Views

      @Ahti said in Inconsistency between model and view after removing a row from a table: JsonObject u_data; u_data.insert("id", model->record(index.row()).value(0).toInt()); u_data.insert("name", model->record(index.row()).value(1).toString()); if (role == Qt::DisplayRole) return u_data; That's inefficient. If you only support DisplayRole, then you can move that QJsonObject directly into that if statement. if (role == Qt::DisplayRole) { QJsonObject u_data; u_data.insert("id", model->record(index.row()).value(0).toInt()); u_data.insert("name", model->record(index.row()).value(1).toString()); return u_data; } Second, you should use the parent here, even if it is a flat list: beginRemoveRows(QModelIndex(), first, last); response = model->removeRow(first, QModelIndex()); beginRemoveRows(parent, first, last); response = model->removeRow(first, parent); But why you get this strange behavior when removing - I don't know. Perhaps it has something to do with the fact that you have two models here - UseModel is a list model and your model variable is a QSqlTableModel (which inherits from the same base class as list model). Perhaps these calls get duplicated, although it is unlikely. Try adding some qDebug() calls into removeRows(), or run it through a debugger, to see what is happening.
    • Example of model/view with custom widget
      General and Desktop • drag and drop custom widget model view prog • • l1q1d56  

      3
      0
      Votes
      3
      Posts
      1595
      Views

      Hi @Joel-Bodenmann , thank you, I got the point about the item delegate but I see two issues: implement a drag and drop listview because I ended up with empty lines (on the list view) and fields on the widget mapper: https://s32.postimg.org/47yyrq7id/Untitled.png implement a delegate that paint a checkbox with custom pixmap, the input with number and the input with text.
    • UNSOLVED One delegate for 2 model object.
      General and Desktop • model-view modelview model view prog delegates • • tokafr  

      2
      0
      Votes
      2
      Posts
      911
      Views

      @tokafr said: Mydelegate *delegate = new Mydelegate; hi, i might miss something but why dont you just create another instance? Mydelegate *delegate2= new Mydelegate; view2 -> setItemDelegate(delegate2); Normally a delegate (instance) is not shared between views as its not intended.
    • When does the model resolve data?
      General and Desktop • model view prog • • Peppy  

      2
      0
      Votes
      2
      Posts
      536
      Views

      Hi, It depends on your implementation. Generally speaking, you trigger the whatever is needed to grab the data over the network and once you have it you populate your model and if done correctly, this will trigger the machinery that will make all view aware that new data are available and they should update. Hope it helps
    • [Solved] New TreeView does not connect to C++ model.
      QML and Qt Quick • qml c++ model-view qtquick2 treeview 5.5 modelview model view prog • • Kofr  

      9
      0
      Votes
      9
      Posts
      5509
      Views

      @Kofr I am stuck into a similar problem, Can you by any chance provide the working code where the TreeView(with parent-child relation) is editable too? Considering that this post was really long back, but it will be a huge help if the code (completed with the qml and C++ too) is provided! Thanks in advance!
    • QTableView how to finish editing procedure when tableView lose focus.
      General and Desktop • model view prog • • sergboec  

      2
      0
      Votes
      2
      Posts
      1017
      Views

      Hi, IIRC it should already be done. What do you have in your delegate ?
    • Model view insert row validation question isDirty()???
      General and Desktop • sql model view prog sqlrelationalta • • lukeQt  

      8
      0
      Votes
      8
      Posts
      2132
      Views

      Do you have an example of this?