Skip to content
QtWS25 Last Chance
  • 0 Votes
    1 Posts
    85 Views
    No one has replied
  • Leveraging Qt models for nested data structures

    Unsolved General and Desktop model qabstractlistmo
    5
    0 Votes
    5 Posts
    2k Views
    E
    Like in your example as of now I think I'd make one tree model. I had considered creating a tree model, but I have some reservations. Store, Department, and Employee have additional responsibilities beyond being simple data containers, and I worry that either I end up decoupling the data from the logic (which goes against OOP principles), or I have to subclass the three classes from a common class, override functions, and therefore haven't achieved clear separation of UI and business logic. To my mind at least, it makes sense to design this as if it were a command line application, and then throw some code on top to interface with a GUI. Maybe that's not the right way to think about things, but I don't like the idea of the GUI framework I'm using dictating how I should structure my data. Aren't you describing a use case for a database and thus Qt's SQL module and its models ? Truthfully, the application has nothing to do with stores, departments, or employees. I changed the names to make the problem easier to reason with. I don't think the data layout is so complex that it justifies introducing relational databases. And besides, with the very frequent live updates coming over the network I can see latency issues arising.
  • 0 Votes
    4 Posts
    437 Views
    S
    I was able to fix this with the following: https://github.com/qt/qtbase/commit/7d92ef63d7c And the following patch in Qt-5.15.2 which tremendously improved the timing: [image: 33f58cff-aeb8-48d6-ac64-d8120b77d822.png]
  • 0 Votes
    4 Posts
    360 Views
    JonBJ
    @jdent You have to iterate through the rows looking for the value you want. If you use a QSortFilterProxyModel you can take advantage of binary search for speed if you sort by primary key. QSqlRelationalTableModel is not important here, all that gives is a "lookup" on one field to map e.g. an integer value to a corresponding string from a related table for display.
  • 0 Votes
    12 Posts
    651 Views
    Christian EhrlicherC
    Please read the docs of submitAll(): "In OnManualSubmit, on success the model will be repopulated. Any views presenting it will lose their selections."
  • 0 Votes
    8 Posts
    758 Views
    H
    The issue was solved Add child model in parent repeater's Compoenet.onCompleted. Repeater { id: repeater1 model: backend.graphModel Component.onCompleted: { repeater2.model = model.GraphMaximumCount } } Repeater { id: repeater2 }
  • 0 Votes
    3 Posts
    375 Views
    S0ulM1keS
    @GrecKo the problem is, that GridView releases it delegates when model's elements is removed. It provokes Image to reload if delegate is shown again. No meter if I set cache: true Such a shame that GridView don't have reuseItems like ListView I've come with next decision. I've created Repeater containing Image that use source model. GridView's delegate Image use Repeater's function itemAt() giving delegate's index after mapping to source model: //Image in deleagte Image { Component.onCompleted: { source = appModelImages.loadImage(appFilterModel.mapRowToSource(parent.delegateIndex)) // custom implementation } ... } //Repeater Repeater { id: appModelImages visible: false function loadImage(index){ return itemAt(index).source } model: AppModel delegate: Image { visible: false asynchronous: true source: model.boxart } } This may be not the best decision, but "faster" than create own delegate pool for GridView. Didn't see any examples of implementing mechanism like this. Repeater should work fine, as it relays on source model. And as I expected, images live when source model does.
  • QVariant to QList

    Solved General and Desktop c++ model
    13
    0 Votes
    13 Posts
    2k Views
    mzimmersM
    @JoeCFD said in QVariant to QList: Understand. Thiink about you can never be number 1 anymore if you play chess. Oddly enough, that was never a concern of mine.
  • 0 Votes
    5 Posts
    593 Views
    P
    @SGaist That's What i want bro Really Thank you <3
  • 0 Votes
    7 Posts
    1k Views
    BeaverShallBurnB
    @JonB Huge thanks, you solved the puzzle for me!
  • 0 Votes
    3 Posts
    553 Views
    G
    @Gojir4 thank you so much
  • QComboBox keep currentText after model update

    Solved General and Desktop qcombobox model widgets
    2
    0 Votes
    2 Posts
    477 Views
    O
    The problem arises from the usage of the method m_model.setStringList(). The latter always clear the previous data, hence the index always reset upon its call. Solution: Use m_model.setStringList() only in the constructor to init the model. After that manually insert the row on the model and set the data for the respective row. This can be achieved with a simple modification in the slot method. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); m_model.setStringList({"1","2"}); ui->comboBox->setModel(&model); } void MainWindow::on_pushButton_clicked() { m_model.insertRow(model.rowCount()); m_model.setData(model.index(model.rowCount()-1), "3"); } In the example above, "3" is appended to the list model without changing the current index from the QComboBox.
  • 0 Votes
    5 Posts
    1k Views
    N
    Hi @LeLev, I tried your solution. Its showing the image. That is fine. Now if i have more elements then its filling in the same space. I need to scroll thorough the screen to see the elements. How to do that ? How should I use Flickable in this case. Note: For example: If the screen layout is 500x500, and each element size id 50x50, then i should only see 16 elements initially. I have to scroll down on the screen to see the remaining elements.
  • Qt Quick 3D use 3D models with skeleton

    Unsolved QML and Qt Quick qt quick 3d model skeleton
    1
    0 Votes
    1 Posts
    441 Views
    No one has replied
  • QtQuick3D access Model skeleton

    Unsolved General and Desktop qtquick3d model skeleton
    1
    0 Votes
    1 Posts
    441 Views
    No one has replied
  • 0 Votes
    2 Posts
    557 Views
    J.HilkJ
    @jeanmilost I can't answer all your questions, as I'm not an expert on Qt's Model/View system, what I do know is, that all models have a QAbstractItemModel as base model and that is also the ABI for all views. For that reason alone, you can assign all models to all views. You will however not get a useful representation of all your data in all views. As I understand it, and anyone fell me to correct me here, the other higher level classes of models are only there to make your life easier, as in you do not have to implement all functions/functionalities of the whole AbstractItemModel class
  • Unable to edit QSqlTableModel from QML

    Unsolved QML and Qt Quick qsqltablemodel sqlite model model-view
    4
    0 Votes
    4 Posts
    825 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.