This question already has answers here:
Signal when a QListView selection changes due to keyboard activity?
(3 answers)
How do I get the items selected from a QListView?
(1 answer)
Closed 3 years ago.
I am using QListView and QFileSystemModel to implement file open dialog due to specific requirement. I don't know how get items which I selected using mouse drag (Multiple Selection) when using QListView::ExtendedSelection. I search Qt doc as well but not found any thing useful.
My requirements are ...
How to know there is multiple selection (signal)
How to get selected item list
Related
Is it possible to "lock" selection in QAbstractView?
I have a form with:
A list of objects I can edit (QTableView).Objects are stored in a database, the list shows their ID.
A New button, whose effect is to append an empty row I can edit to create a new ID and enable controls in the rest of the form.
An Edit button whose effect is to enable the edition of the rest of the form, but leaves the ID non editable.
Everything is driven by a state machine. There are parallel states but for the sake of this question, only transition between a Viewing state and an Editing state is relevant. Clicking either button enters the Editing state, which means testing if I am in the Editing state provides no information about whether I clicked on New or on Edit.
I am trying to lock the selection when entering the Editing state.
I cannot simply disable the view because I need to edit new IDs, I cannot connect a slot to the selectionChanged signal to restore the selection because of side effects (calls to the database + focus going all over the place), and if possible, I wish to avoid having to call QAbstractItemView::setSelectionModel (it is reset by QAbstractItemView::setModel, see below) and wish to drive this behavior thanks only to the Viewing and Editing states.
I have tried to use, but to no avail:
QAbstractItemModel::flags (the best I can do is prevent selecting another item but not clearing the selection.)
QAbstractItemView::selectionMode
QItemSelectionModel::select, with QItemSelectionModel::SelectionFlag::NoUpdate (The description of this enum value made me think it could block the next selection change but that is not the case).
Subclassing QItemSelectionModel (#chehrlic's comment below) to override all the virtual public slots.While it does work (a property can be used to stop the selection from changing), it is a pain that QAbstractItemView::setModel creates a new model. It does work now but I do not see any easy way to prevent the code from breaking after accumulating code changes over the span of several years.
Did I miss any existing property to achieve this? And if I did not, how can I implement a property to lock the selection but no have any other effect on my view?
At this point, the last item in the above list of things I tried does do the job but it has a downside I am trying to avoid.
This is similar to this question except it was for a now old version of Qt and the answer is not very satisfying anyway.
This question already has answers here:
Django: adding an "Add new" button for a ForeignKey in a ModelForm
(3 answers)
Closed 6 years ago.
I really can't find the right words to Google this so I am here to find help. I want to use the idea of the admin page in django where when you add an information and it has a foreign key, a plus sign is present beside the field and with that, you can add data that pops up in a new window and after saving, the new data automatically reflects the selection.
Okay. I solved the add button. Now what I want is the data will appear after saving in the select drop down. I haven't had the answer to it yet
This is easy, if even the other model(which is your foreign key) is added to the Admin. It directly shows the plus button. But, if you don't want that.
I guess you are searching for InlineModelAdmin.
This question already has answers here:
Ember.js Data how to clear datastore
(7 answers)
Closed 9 years ago.
In the Ember.js application I'm working on, that uses Ember-data, once the user gets to a point on the screen, I want to delete all state stored in the ember-data Store associated with the application, and start with a clean slate that can start pulling data from the server. Anyone know how to do it?
I don't think there is an easy way. The only way ATM is loop over all your DS.Model classes and destroy the records individually.
App.Model.all().forEach(model) ->
model.destroy();
App.Model2.all().forEach(model) ->
model.destroy()
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have a combobox that holds a list of different command types. I want to change the visible input fields on my GUI depending on the selected command in the combobox. I am very new to Qt, and I would appreciate it if someone could point me in the right direction to implementing this.
My current idea is to have a "select" button that emits a signal, and the connected slot will grab the current index of the combobox. I THINK I need to implement a custom class to hold a QFrame. The custom class will hold slots that indicate which data inputs (for the selected command) should be displayed in the QFrame.
IE, if COMMAND_1 is selected in the combobox, 3 input fields display in the QFrame. If COMMAND_2 is selected, a pair of radio buttons is displayed in the QFrame, and those 3 input fields are hidden or deallocated.
Is this a good way of attempting to solve this problem?
You're going about it the right way. But Qt actually makes it even easier than what you're thinking.
You can use two built-in widgets: QComboBox and QStackedWidget. You're familiar with the combo box; the stacked widget is a set of widgets, of which only one will be displayed at a time. It's essentially a tabbed widget minus the tabs.
Set up your stacked widget so that its first widget is what you want to show when your combo box is showing its first option, the second for the second, and so on. Then you can connect a built-in signal to a built-in slot: QComboBox::currentIndexChanged(int) to QStackedWidget::setCurrentIndex(int).
Hope that helps!
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Getting Facebook profile pic from user (via Graph) - detect if it's a blank (i.e. default) image?
As on facebook site, it will display the creator's the picture if the event does not have a custom profile picture, I want to know if there is a flag to indicate it.
Thanks
There is no flag to indicate this. /eventid/picture just returns the URL, no flags. For more information http://developers.facebook.com/docs/reference/api/event/