Вы должны добавить скобки для вызова метода FirstOrDefault
var frenchvoice = InstalledVoices.All
.Where(voice => voice.Language.Equals("fr-FR") &&
voice.Gender == VoiceGender.Female)
.FirstOrDefault();
И, в то время как ваш код работает также с использованием & amp; оператор, правильный для использования в логическом условии: &&
Кстати, FirstOrDefault
принимает ту же лямбду, что и для Where, чтобы вы могли сократить свой код до более простого и, возможно, более быстрого
var frenchvoice = InstalledVoices.All
.FirstOrDefault(voice => voice.Language.Equals("fr-FR") &&
voice.Gender == VoiceGender.Female);
Are from the "Mode/View framework"
This is a very powerful framework for the data part of your application, here is a presentation of the framework.
QAbstractItemModel
Is the base class for the model of the MVC. Has a global interface for accessing and altering the data and takes care of the Observable part.
QAbstractItemView
Is the base class for the view of the MVC. Has aglobal interface for the view/selections part and it takes care of the Observer part. You don't have to worry about the observer pattern, the framework does it for you.
QAbstractItemDelegate
Is the base class for the controller of the MVC.
Is the Strategy pattern for painting, editing the elements, ...
Are from the "The Graphics View Framework" and is independent of the Model/View framework.
This is also a very powerful framework for the graphics part.
The Scene
QGraphicsScene provides the Graphics View scene. The scene has the following responsibilities:
Providing a fast interface for managing a large number of items Propagating events to each item Managing item state, such as selection and focus handling Providing untransformed rendering functionality; mainly for printing
The View
QGraphicsView provides the view widget, which visualizes the contents of a scene. You can attach several views to the same scene, to provide several viewports into the same data set
If you want a Model to be visible in a QGraphicsView than you will have to write your own view based on the QAbstractItemView.
Take a QGraphicsView as view port widget QAbstractScrollArea::setViewport(QWidget * widget))
and then you can
QAbstractItemView::rowsInserted
, QAbstractItemView::rowsAboutToBeRemoved
QAbstractItemView::dataChanged
the items in the scene. Don't forget to take care of the reset an layout change events.