Skip to content
  • QWidget 3D Model

    Unsolved General and Desktop 3d model 3dmodule model-view modelview qwidget
    5
    0 Votes
    5 Posts
    243 Views
    J
    @Pl45m4 said in QWidget 3D Model: I think using QtQuick 3D might be the easiest and best way for your case. I'm sure you will find more examples out there. thank you so much, I am here for you :D, I will wait... @Pl45m4 said in QWidget 3D Model: Do you already have the model + textures etc.? I do not have not yet but I can find free like you said @Pl45m4 said in QWidget 3D Model: Hahaha that stick figure out of nowhere made me laugh :D <3
  • 0 Votes
    9 Posts
    959 Views
    R
    @Saviz dataChanged() signal is the primary reason your GUI knows data has been changed within your model and updates it accordingly.
  • 0 Votes
    4 Posts
    1k Views
    jeremy_kJ
    @jaivardhanf said in How to change QTableView data based on selection in QComboBox.: So below is my code. Something seems to have gone wrong with the code tags, making it hard to read and potentially missing code. Qt::ItemFlags LineModel::flags(const QModelIndex& index) const { return Qt::ItemIsEditable | QAbstractTableModel::flags(index); } Adding the ItemIsEditable flag doesn't matter if the goal isn't to edit the item through the view. This is how I connect the signal and slot connect(ui->lineClass, &QComboBox::currentTextChanged, this, &GetOptionsClass::TextChanged); Verify that the slot is called when it should be, and that the arguments are as expected.
  • 0 Votes
    9 Posts
    2k Views
    VRoninV
    @firen said in Sync selectionModel between two views where one view has a transposed Model of the other: That seems ok for my needs Try inserting/removing rows/columns or sorting and you'll see it will break
  • 0 Votes
    5 Posts
    1k Views
    JonBJ
    @AlexandruToma No, you will impose sorting via a QSortFilterProxyModel on top of your model if sorting is wanted. View will access that. Your indexes here will be unaffected. That is why a proxy model is nice :)
  • 0 Votes
    2 Posts
    706 Views
    E
    Still not sure what's the best design here.
  • Unable to edit QSqlTableModel from QML

    Unsolved QML and Qt Quick qsqltablemodel sqlite model model-view
    4
    0 Votes
    4 Posts
    1k Views
    sierdzioS
    @daljit97 said in Unable to edit QSqlTableModel from QML: , Qt::EditRole); Then you should probably pass the role and not editRole, otherwise model won't know which column to update.
  • Making a VST Effect Stack using Model/View

    Unsolved General and Desktop model-view vst listwidget
    5
    0 Votes
    5 Posts
    2k Views
    R
    @SGaist Thanks, I will dig into it more
  • Disable Qt::CheckStateRole

    Unsolved General and Desktop model-view
    4
    0 Votes
    4 Posts
    3k Views
    Christian EhrlicherC
    You can use a QIdentityProxyModel
  • 0 Votes
    9 Posts
    2k Views
    SGaistS
    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.
  • 0 Votes
    7 Posts
    1k Views
    AhtiA
    @SGaist @Christian-Ehrlicher How would I let the view know about the data change ? And I would like to mention I am displaying the list of users with UserRole like this: QVariant UserModel::data(const QModelIndex &index, int role) const{ QVariant value; if (index.isValid()) { if (role < Qt::UserRole) value = QSqlQueryModel::data(index, role); else { int columnIdx = role - Qt::UserRole - 1; QModelIndex modelIndex = this->index(index.row(), columnIdx); value = QSqlQueryModel::data(modelIndex, Qt::DisplayRole); } } return value; } QHash<int, QByteArray> UserModel::roleNames() const{ QHash<int, QByteArray> roles; for (int i = 0; i < record().count(); i ++) { roles.insert(Qt::UserRole + i + 1, record().fieldName(i).toUtf8()); } return roles; }
  • 0 Votes
    2 Posts
    601 Views
    JonBJ
    @Ahti Dunno, but why don't you start by showing us/yourself the return values of the calls to user_model.setData(user_model.index(...? What's the result for you of: https://doc.qt.io/qt-5/qsqltablemodel.html#editStrategy ?
  • 0 Votes
    2 Posts
    1k Views
    IntruderExcluderI
    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.
  • 0 Votes
    2 Posts
    612 Views
    sierdzioS
    @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.
  • What to subclass?

    Solved General and Desktop qsqlquerymodel subclassing model-view editable model
    9
    0 Votes
    9 Posts
    2k Views
    Pl45m4P
    @christian-ehrlicher said in What to subclass?: Especially compared to the idea to parse the data somehow from a sqlite file Where I have said that? :) I never had the idea to "parse" the sqlite file directly. I will try to get the data with a query first and see what I can do with it :) (I guess QSqlResult is the key?!)
  • 0 Votes
    12 Posts
    2k Views
    JKSHJ
    @overlord said in Using QAbstractItemModel in Models that haven't any list.: I am invastigating proper way to use model/view pattern. The model/view pattern in Qt is designed for cases where you have an arbitrary number of rows of data. Your sensors don't quite match this use-case. Therefore, the model/view pattern is not suitable for your sensors. I suggest you choose the right tool for the job: Just use a data structure for your sensors, like @SGaist suggested. If you want to investigate how to use the model/view pattern, try implementing a model with rows. For example, an address book.
  • Using Qt's Model/View pattern on custom UIs

    Unsolved QML and Qt Quick model-view
    3
    0 Votes
    3 Posts
    806 Views
    overlordO
    I will show one datasets at the same time. This data periodically updated. So I haven't any list.
  • 0 Votes
    27 Posts
    7k Views
    VRoninV
    Can you reformat the answer? it's difficult to follow...
  • 0 Votes
    7 Posts
    3k Views
    Pl45m4P
    @Christian-Ehrlicher Hm ok... That's not what I wanted to hear :D Thank you anyway. I think, I will subclass QSqlQueryModel then and write functions to make the model writable...