model-view

Sorting QtTableModel - QTableView doesn't get updated

╄→гoц情女王★ 提交于 2019-12-14 01:07:37
问题 I implemented a custom QAbstractTableModel and I'm using a std::vector for my data objects. Now I wanted to implement the sort() method, to get my table sorted by column. That's basically what I do: void SBStateTableModel::sort (int column, Qt::SortOrder order) { emit layoutAboutToBeChanged(); switch (column) { case Address: if (order == Qt::DescendingOrder) std::sort(states.begin(), states.end(), addr_comp_desc); else std::sort(states.begin(), states.end(), addr_comp_asc); default: return; }

MVC 4 textbox not updating on postback

☆樱花仙子☆ 提交于 2019-12-13 18:31:07
问题 I have a form that uses a modelview object that is not updating a textbox value on postback of submitting a form. On submitting a form, I edit the property of an object that is binded to a textbox. When the form comes back, the object property is still changed, but the textbox value does not change. It's like the textbox value is cached and will not change. How do I fix this? Textbox default value: "" Textbox code: @Html.TextBoxFor(m => m.Project.tNumber, new { @readonly = "readonly", @class

Notify PropertyChanged after object update

大城市里の小女人 提交于 2019-12-13 04:36:23
问题 I wish to update my listview in an elegant way. This is my code: ObservableCollection<Track> tracks = new ObservableCollection<Track>(); Track track = new Track(); Tracks.AddRange(track); // collection add a track, and list view updates too Task.Factory.StartNew(() => track.GetInfo(); // this operation might require some times to update // here I need to notify that my object is updated ); How i can force to update binding of an object inside my ObservableCollection ? This is my userControl

Model binding for a ViewModel containing multiple objects

北慕城南 提交于 2019-12-13 03:49:10
问题 I have a strongly typed view of type ProductListingViewModel which in turn contains a ProductViewModel. (both custom view models). I have some form elements on my page and these are created like so: <%: Html.DropDownListFor(m => m.ProductViewModel.CategoryId, Model.Categories)%> which generates the HTML: <select name="ProductViewModel.CategoryId" id="CategoryId"> With the default model binding I expected that when I post to my controller action which accepts a parameter of type

KnockoutJS and PubSub to update observable array between views

大城市里の小女人 提交于 2019-12-11 17:51:38
问题 I have two modalviews - MyModalViewA (parent) and MyModalViewB (child). MyModalViewA spawns MyModalViewB , as custom binding, as well has observable array which I need to update. And it looks like: (function () { 'use strict'; var window = __webpack_require__(/*! window */ 10), _ = __webpack_require__(/*! _ */ 2), $ = __webpack_require__(/*! $ */ 12), ko = __webpack_require__(/*! ko */ 3), key = __webpack_require__(/*! key */ 16), Enums = __webpack_require__(/*! Common/Enums */ 4), Utils = _

No injector factory bound for Class<>

感情迁移 提交于 2019-12-11 16:21:29
问题 I saw the same question in stack but they try to fix the error with the @ContributesAndroidInjector but in Dagger documentation says use @ContributesAndroidInjector is only optional, so here are my classes: My MainActivityComponent : @Subcomponent(modules = [ MainBuilder::class ]) @ActivityScope interface MainComponent: AndroidInjector<MainActivity>{ @Subcomponent.Factory interface Factory: AndroidInjector.Factory<MainActivity> } My AplicationBinder : @Module(subcomponents = [ MainComponent:

How to properly design an MV application in Java Swing?

十年热恋 提交于 2019-12-11 13:18:41
问题 I'm trying to design an MV (Model-ViewController) application in Java swing. I'm having trouble with assigning the correct model to each ViewController. Here's my current design (not the actual names) : The idea is that I have two views : the Gui and a Midi Device. Each view has its corresponding model. However, a part of the Gui (ButtonBar) needs to access the midi device model. For now, my solution is to pass the MidiDevice model to the MainWindow's constructor, then let it pass it down to

QDataWidgetMapper: wrong mapping

删除回忆录丶 提交于 2019-12-11 05:47:52
问题 I am desperately trying to figure out how the QDataWidgetMapper works. Therefore, I wrote a small demo application with a custom model derived from QAbstractTableModel . If I run the application, I would assume, that I get the following output: Firstname: Walter Surname: Pinkman However, I get: Firstname: Jesse Surname: Pinkman What am I missing? I also tried to change the orientation-property of QDataWidgetMapper , but then I get: Firstname: White Surname: Pinkman example: #!/usr/bin/env

QTableView to display only leaves of a tree model implemented with QAbstractItemModel

拥有回忆 提交于 2019-12-10 20:58:18
问题 Assume I have a tree structure (tree leaves in bold , sorry for the dots): A A1 A2 B B1 B11 B2 C stored in a QAbstractItemModel (with set parent/child relations). How to display only the tree leaves in a QTableView? Basic idea was to implement a QSortFilterProxyModel. Intuition suggested there would be a way to iterate through the tree and return a valid index if the item is a leaf, or QModelIndex() if not. // QAbstractItemModel *model; m_leavesModel.setSourceModel(model); //

canFetchMore() and fetchMore() are not working as expected

99封情书 提交于 2019-12-10 11:18:16
问题 I have problems implementing Qt tree model with lazy loading using canFetchMore() and fetchMore() . I have this code: from PySide.QtCore import Qt, QAbstractItemModel, QModelIndex from PySide.QtWidgets import QTreeView, QApplication BATCH_SIZE = 100 class ObjectItem(object): def __init__(self, parent, name, data, row): self.parent = parent self.name = name self.data = data self.row = row self.hasChildren = False self.canFetchMore = False # ints have no children if isinstance(data, int):