Navigation

    Qt Forum

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

    • UNSOLVED What to subclass?
      General and Desktop • model-view qsqlquerymodel subclassing editable model • • Pl45m4  

      9
      0
      Votes
      9
      Posts
      124
      Views

      @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?!)
    • UNSOLVED Using QAbstractItemModel in Models that haven't any list.
      QML and Qt Quick • qml model-view qabstractmodel • • overlord  

      12
      0
      Votes
      12
      Posts
      177
      Views

      @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.
    • UNSOLVED Using Qt's Model/View pattern on custom UIs
      QML and Qt Quick • model-view • • overlord  

      3
      0
      Votes
      3
      Posts
      101
      Views

      I will show one datasets at the same time. This data periodically updated. So I haven't any list.
    • UNSOLVED Need help from QT Experts ( Model / View for QDateTimeEdit widget)
      General and Desktop • model-view qdatetimeedit qdatawidgetmapp • • chakry  

      27
      0
      Votes
      27
      Posts
      797
      Views

      Can you reformat the answer? it's difficult to follow...
    • SOLVED Showing data from multiple SQLite tables
      General and Desktop • database model-view sqlite view • • Pl45m4  

      7
      0
      Votes
      7
      Posts
      376
      Views

      @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...
    • SOLVED UI Responsiveness and QListView updating during load of large data into model
      General and Desktop • model-view responsive • • bepaald  

      10
      0
      Votes
      10
      Posts
      1011
      Views

      Boiler plate code which you are trying to implement is already taken care by Qt using Signals/Slots across threads. It is better to use tried & tested inbuilt mechanism. It is good with code maintainability & readability as well. Suggest to use signals/slots.
    • UNSOLVED How to add tooltip to Tableview from C++ model
      General and Desktop • qml model-view tooltip • • milan  

      16
      0
      Votes
      16
      Posts
      1329
      Views

      @milan Hi, You can do it using a delegate and a ToolTip component: import QtQuick.Controls 2.2 as QC2 ... TableViewColumn { id: titleColumn title: "Title" role: "title" movable: false resizable: false width: tableView.viewport.width - authorColumn.width delegate: QC2.ItemDelegate{ id: lb hoverEnabled: true text: model.title width: parent.width QC2.ToolTip { delay: 250 parent: lb visible: lb.hovered text: "Tooltip text" //put styleData.tooltip here } } } This code is extracted from the TableView example which I have modified to add the ToolTip.
    • UNSOLVED Tree View with varying column counts
      General and Desktop • qtreeview model model-view treemodel • • DaveK 0  

      1
      0
      Votes
      1
      Posts
      231
      Views

      No one has replied

    • UNSOLVED What layout to use for data listing if I don't need most of the model features?
      General and Desktop • model-view table model • • lansing  

      3
      0
      Votes
      3
      Posts
      332
      Views

      @mrjj Thanks I got it to work. ui->setupUi(this); ui->tableWidget->setColumnCount(2); ui->tableWidget->setRowCount(numberSet.size()); ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); QStringList tableHeader = {"Number", "Result"}; ui->tableWidget->setHorizontalHeaderLabels(tableHeader); int rowCounter = 0; for(int i : numberSet) { ui->tableWidget->setItem(rowCounter, 0, new QTableWidgetItem(QString::number(i))); ui->tableWidget->setItem(rowCounter, 1, new QTableWidgetItem(someConversion(i))); rowCounter++; }
    • SOLVED Replicate the contents of the current selected item in QTableView
      General and Desktop • qtableview signal & slot model-view view • • Arthur Araruna  

      7
      0
      Votes
      7
      Posts
      857
      Views

      @Arthur-Araruna said in Replicate the contents of the current selected item in QTableView: both column and row indices All you need to do is replace currentRowChanged with currentIndexChanged
    • SOLVED Custom Widget in QListView/QTreeView expands whole width
      General and Desktop • model-view custom widget modelview • • SKovalev  

      4
      0
      Votes
      4
      Posts
      649
      Views

      Finaly I have finished my little example! Previous version have been really buggy in items move. So I have to subclass from QAbstractItemModel. Many thanks to @Patou355 with his solution. NB I haven't deal with mousePressEvent() yet.
    • SOLVED Implementing chat type listview with text bubbles
      General and Desktop • qlistview model-view custom item chatting textsize • • bepaald  

      10
      0
      Votes
      10
      Posts
      1767
      Views

      @SGaist thank you, it has worked a treat! I appreciate your help. Steve Q.
    • SOLVED Dynamically change a component
      QML and Qt Quick • model-view load dynamic qml • • MoaMoaK  

      5
      0
      Votes
      5
      Posts
      1514
      Views

      Ok, nice, these three answers (StackView / StackLayout / Loader + Component) were what I was looking for. I tried each one and I think I'll stick with the StackView and the replace method as it's easy to have a fading transition with it. And I've already found a use to improve my code for the Loader so I also thank you for that. Thx for the help.
    • UNSOLVED Implementing Drag and Drop with QTreeView
      General and Desktop • model-view drag and drop treeview itemmodel • • jonasqt  

      1
      0
      Votes
      1
      Posts
      1561
      Views

      No one has replied

    • SOLVED One or Multiple QtTreeModel(s) in different Tabs?
      General and Desktop • model-view mvc tabs treemodel • • Opa114  

      13
      0
      Votes
      13
      Posts
      2839
      Views

      thanks. i will try it :)
    • SOLVED How to retrieve items indices from a treeView?
      QML and Qt Quick • qml model-view treeview index delegates • • Haitham  

      11
      0
      Votes
      11
      Posts
      4232
      Views

      @VRonin Can you please provide an example or something to follow? Because I am still a newbie at both Qt and QML. Sorry for bothering you with my many questions. Update: as you can see in the code, I change the state of the delegate through the mouse area in the delegate (it's commented out in the code). I was using it to test the states, now I've noticed another thing; Whenever I collapse the parent Item and then expand it, the previous states are not saved....does this have to do anything with what you mentioned?
    • UNSOLVED QAbstractTableModel hard to set up
      General and Desktop • qtableview qtablewidget model-view qabstracttablem qtablewidgetite • • moffa13  

      3
      0
      Votes
      3
      Posts
      998
      Views

      In 90% of the cases you can use QStandardItemModel instead of going through the minefield that is subclassing an abstract model. My advice is just to use that "universal model" instead of a custom one. If you really, really want to customise it as performance of QStandardItemModel is a problem then make sure you run your model through the Model Test (needs just a couple of trivial fixes to work on Qt5) that will tell you if you did everything as you were supposed to or you fell in the countless pitfalls of model subclassing
    • UNSOLVED QML TreeView - how to apply delegate to certain items in the tree?
      QML and Qt Quick • qml model-view delegate treeview • • Haitham  

      9
      0
      Votes
      9
      Posts
      5837
      Views

      @6thC did your application consist of a tree and you could apply a delegate to specific items? because that's where I'm stuck now. I am still researching on how to connect QML with C++ and as usual if I figured out a way of applying delegates to specific items based on a logical condition (like your warning and maximum states), I will let you know. Thanks for your time bro!
    • SOLVED change QSortFilterProxyModel behaviour for multiple column filtering
      General and Desktop • qtableview model-view qsortfilterprox qstandarditemmo filtering • • IMAN4K  

      9
      0
      Votes
      9
      Posts
      4745
      Views

      @IMAN4K said in change QSortFilterProxyModel behaviour for multiple column filtering: Answer from stackfverflow : http://stackoverflow.com/questions/39488901/change-qsortfilterproxymodel-behaviour-for-multiple-column-filtering This answer is the typical example that lead people to say subclassing QSortFilterProxyModel, which would likely have a very limited reusability It's bad. the proxy model implementation should not depend on the structure of the underlying data in sourceModel
    • UNSOLVED How to disable filtering option for a QTreeView or Model?
      General and Desktop • qtreeview model-view • • NIXIN  

      4
      0
      Votes
      4
      Posts
      1130
      Views

      @NIXIN class MySortFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT Q_PROPERTY(bool FilterEnabled READ isFilterEnabled WRITE setFilterEnabled ) public: virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const { if( !m_IsFilterEnabled ) return true; // your filtering code here } bool isFilterEnabled() const { return m_IsFilterEnabled }; void setFilterEnabled( bool enabled ) { if( m_IsFilterEnabled != enabled ) { m_IsFilterEnabled = enabled; this->invalidate(); } } private: bool m_IsFilterEnabled;
    • SOLVED QAbstractListModel as property
      General and Desktop • qml c++ model-view qt5.7 qabstractlistmo • • romsharkov  

      3
      0
      Votes
      3
      Posts
      2712
      Views

      @SGaist returning a pointer in the getter and defining the Q_PROPERTY as a pointer to the list worked out fine! Thanks for that!
    • UNSOLVED Updating a proxy model
      General and Desktop • model-view • • KlimichKartorGnusov  

      8
      0
      Votes
      8
      Posts
      2185
      Views

      Like I said, without seeing any code I can't comment on whether the wrong index is being used or something else is going on.
    • SOLVED Transforming and filtering a model
      General and Desktop • model-view • • KlimichKartorGnusov  

      6
      0
      Votes
      6
      Posts
      1452
      Views

      You don't need all of this. Just use the top-most index. Modifying its content will propagate it back to the bottom index.
    • UNSOLVED Set minimum column width to QTableView.
      General and Desktop • qtableview model-view mvc qheaderview • • tokafr  

      5
      0
      Votes
      5
      Posts
      10998
      Views

      Hi, You can try with the QHeaderView::minimumSectionSize property
    • UNSOLVED One delegate for 2 model object.
      General and Desktop • model-view modelview model view prog delegates • • tokafr  

      2
      0
      Votes
      2
      Posts
      811
      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.
    • UNSOLVED How to style QTreeView items by role with CSS ?
      General and Desktop • qtreeview model-view css qtwidgets styles • • Zylann  

      9
      0
      Votes
      9
      Posts
      5616
      Views

      I finally managed to get custom colors. I gave my QTreeView an object name to be able to write this in CSS: m_treeView->setObjectName("MyTreeView"); m_treeView->setStyleSheet("QTreeView#MyTreeView::item {color: none;}"); basically now my model controls text color through Qt::ForegroundRole regardless of the application's CSS. I feel like it's the wrong place to put theming, but it works for me at the moment. Well... until we decide to have different themes :-°
    • UNSOLVED [SOLVED]QTableModel crashes on headerData
      General and Desktop • model-view qabstracttablem • • RDiGuida  

      10
      1
      Votes
      10
      Posts
      2627
      Views

      @RDiGuida Ok, so cnamMet would run out of scope and be deleted (when function ended) but sounds like data.rnames should have been working. Well if a copy on creation time works for you, its a wrap :)
    • SOLVED Speed up multiple setData() calls in model
      General and Desktop • model-view qtconcurrent setdata • • panosk  

      12
      0
      Votes
      12
      Posts
      3107
      Views

      @mjsurette That did the trick! I also removed the dataChanged() calls and now the operation executes instantly even with thousands of rows. It also seems there aren't any side effects, apart that I have to call again fetchMore() immediately after select(). I can now move on and implement some other batch operations like this without worrying about speed. Thank you!
    • UNSOLVED Photo Album Example
      QML and Qt Quick • model-view mvc folderlistmodel xmllistmodel m-v-delegate • • Anas A. Ismail  

      1
      0
      Votes
      1
      Posts
      589
      Views

      No one has replied

    • How to use modelData without one element?
      General and Desktop • qml model model-view data • • sosun  

      1
      0
      Votes
      1
      Posts
      440
      Views

      No one has replied

    • Using QComboBox with QSqlQueryModel
      General and Desktop • c++ qt4 qcombobox model-view item qsqlquerymodel data • • Aleksey_K  

      2
      0
      Votes
      2
      Posts
      1696
      Views

      Yeah, according to QComboBox code should work: QVariant QComboBox::itemData(int index, int role) const { Q_D(const QComboBox); QModelIndex mi = d->model->index(index, d->modelColumn, d->root); return d->model->data(mi, role); } Will implement this.
    • [Solved] Model/View design question
      General and Desktop • model-view • • Joel Bodenmann  

      7
      0
      Votes
      7
      Posts
      1572
      Views

      Sounds reasonable. Thank you for your help!
    • TableViewColumn displaying data based on two roles (TreeView)
      General and Desktop • qml model-view treeview qstandarditem role • • BPie  

      1
      0
      Votes
      1
      Posts
      553
      Views

      No one has replied

    • Historic QComboBox with QStringListModel
      General and Desktop • qcombobox model-view subclassing • • ssenegas  

      1
      0
      Votes
      1
      Posts
      1051
      Views

      No one has replied

    • How to inherit QObject based abstract class in two QWidget/QGraphicsScene views
      General and Desktop • model-view qobject slots • • Resurr3ction  

      4
      0
      Votes
      4
      Posts
      2714
      Views

      @JKSH Ah, moc assumes first class only. So its simply not supported. Thats good to know.
    • [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  

      8
      0
      Votes
      8
      Posts
      4869
      Views

      @Valerian I did not do d&d yet. In my idea you should register a signal to be emitted whenever you move mouse in the area of new position and call swap function. Do you feel something like this?
    • [solved]Problem with QSortFilterProxyModel and calculated field.
      General and Desktop • model-view proxy • • mjsurette  

      1
      0
      Votes
      1
      Posts
      649
      Views

      No one has replied

    • Flat leaf Proxy
      General and Desktop • model-view • • VRonin  

      2
      0
      Votes
      2
      Posts
      819
      Views

      How are you viewing the model?
    • Interfacing QT Quick with QSql Backend via QsqlRelationalTableModel
      QML and Qt Quick • qtquick qt quick qt 5.4 model-view qtsql • • Sam2304  

      2
      0
      Votes
      2
      Posts
      1225
      Views

      @Sam2304 The following post may be useful in the resolution of this: How to integrate QSqlTableModel with a tableview defined in qml