久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<small id='p5EGl'></small><noframes id='p5EGl'>

    <i id='p5EGl'><tr id='p5EGl'><dt id='p5EGl'><q id='p5EGl'><span id='p5EGl'><b id='p5EGl'><form id='p5EGl'><ins id='p5EGl'></ins><ul id='p5EGl'></ul><sub id='p5EGl'></sub></form><legend id='p5EGl'></legend><bdo id='p5EGl'><pre id='p5EGl'><center id='p5EGl'></center></pre></bdo></b><th id='p5EGl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='p5EGl'><tfoot id='p5EGl'></tfoot><dl id='p5EGl'><fieldset id='p5EGl'></fieldset></dl></div>
      <bdo id='p5EGl'></bdo><ul id='p5EGl'></ul>
    <tfoot id='p5EGl'></tfoot>

  1. <legend id='p5EGl'><style id='p5EGl'><dir id='p5EGl'><q id='p5EGl'></q></dir></style></legend>

    1. Qt 模型-視圖-控制器

      Qt Model-View-Controller(Qt 模型-視圖-控制器)
    2. <small id='V5LHW'></small><noframes id='V5LHW'>

        <i id='V5LHW'><tr id='V5LHW'><dt id='V5LHW'><q id='V5LHW'><span id='V5LHW'><b id='V5LHW'><form id='V5LHW'><ins id='V5LHW'></ins><ul id='V5LHW'></ul><sub id='V5LHW'></sub></form><legend id='V5LHW'></legend><bdo id='V5LHW'><pre id='V5LHW'><center id='V5LHW'></center></pre></bdo></b><th id='V5LHW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='V5LHW'><tfoot id='V5LHW'></tfoot><dl id='V5LHW'><fieldset id='V5LHW'></fieldset></dl></div>
          <bdo id='V5LHW'></bdo><ul id='V5LHW'></ul>
        • <tfoot id='V5LHW'></tfoot>

                <tbody id='V5LHW'></tbody>

              • <legend id='V5LHW'><style id='V5LHW'><dir id='V5LHW'><q id='V5LHW'></q></dir></style></legend>
              • 本文介紹了Qt 模型-視圖-控制器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                首先,我想說我已經閱讀了有關 Qt 和 MVC 的所有其他問題,但是我找不到我要找的內容.因此,除非您在舊問題中找到了實際回答我的問題的內容,否則請不要將它們與我聯系起來.我也在 qt.dgia.com 和 qt.project.com 中搜索過,但還是沒有運氣.

                First of all I would like to say that I' ve already read all the other questions about Qt and MVC, but I couldn't find what I'm looking for. So please, unless you find something in the old questions that actually answer my question, don't link them to me. I also searched in qt.digia.com and qt.project.com but again, no luck.

                現在來解決我的問題.我必須實現一個簡單的圖像比較器,它可以并排顯示圖像,以便可以比較它們.我必須使用 MVC 來做到這一點.我的問題是我從未使用過 Qt,我對如何將它與 MVC 一起使用感到有些困惑.

                So now to my problem. I have to implement a simple image comparator that shows to image side by side so that they can be compared. I have to use MVC to do this. My problem is that I've never used Qt and I'm a bit confused on how to use it with MVC.

                特別是,我想知道 MainWindow 應該從哪個子類化.是視圖還是模型,還是兩者兼而有之?這是我的想法. MainWindow 是我的類圖中的一個視圖,但我不確定,因為它也有模型的元素,因為它實際上存儲了數據信息.你有什么建議?那么如何設計其他類呢?謝謝.

                In particular, I am wondering what MainWindow should be subclassed from. It is the View or the Model, or both? This is what I thought. MainWindow is a View in my class diagram, but I'm not sure of that, because it also has elements of a model, since it actually stores data information. What do you suggest? Then how would design the other classes? Thank you.

                推薦答案

                Qt 并未整體實現標準"MVC 模式 - 您需要從頭開始重新實現這樣的框架.Qt 提供了一個模型視圖框架,為 MVVM 提供了足夠的功能,但這不是 MVC 的書本.

                Qt does not implement the "standard" MVC pattern as a whole - you would need to reimplement such a framework from scratch. Qt offers a model-view framework that offers enough functionality for MVVM, but that's not MVC-by-the-book.

                在 Qt 的實現中,視圖和控制器混合在一起.視圖是向用戶顯示模型以及用戶在代理的幫助下與模型交互的內容.

                In Qt's implementation, the view and the controller are mingled together. The view is what shows the model to the user and what the user uses to interact with the model, with help of delegates.

                因此,單獨控制器的問題基本上沒有實際意義,因為沒有.在 Qt 中,具體視圖是您通常不會從中派生的獨立小部件.相反,您將視圖集成(has-a)到一個包含其他控件的更大的小部件中.

                Thus, the question of a separate controller is essentially moot, as there isn't one. In Qt, a concrete view is a stand-alone widget that you normally don't derive from. Instead, you integrate (has-a) the view into a larger widget that holds other controls.

                Qt 提供了一些標準視圖(列表視圖、表格視圖和樹視圖).還有 QDataWidgetMapper 可以讓您將模型中的一個索引映射到任何小部件的用戶屬性.還有多種型號可供選擇.抽象模型是您自己實現的基礎.然后是 QStandardItemModel,它提供了靈活的數據樹/表存儲.最后,QSqlQueryModelQSqlRelationalTableModel 將 SQL 數據庫作為模型公開.

                Qt provides some standard views (a list view, a table view and a tree view). There's also the QDataWidgetMapper that lets you map one index from a model onto the user property of any widget. There are also several models to choose from. The abstract models are bases for your own implementations. Then there's the QStandardItemModel that provides a flexible tree/table storage of data. Finally, QSqlQueryModel and QSqlRelationalTableModel expose SQL databases as models.

                在下面的示例中,比較器被實現為一個視圖模型 - 一個代理,用比較的結果修改底層圖像提供模型.對于要顯示的圖像,需要在 Qt::DecorationRole 下提供它們.主窗口只是視圖(is-a),不需要子類化.

                In the example below, the comparator is implemented as a viewmodel - a proxy that amends the underlying image-providing model with results of the comparison. For the images to be displayed, they need to be provided under the Qt::DecorationRole. The main window is simply the view (is-a), and no subclassing is necessary.

                #include <QApplication>
                #include <QTableView>
                #include <QIdentityProxyModel>
                #include <QStandardItemModel>
                #include <QPainter>
                
                /** Adds image comparison results to a table/tree with pairs of images in each row.
                 *
                 * This is a viewmodel that expects a table or tree with row containing pairs of images in the
                 * first two columns. Comparison results are visualized as the added last column.
                 * A null result is provided for rows that don't have two images as their first two columns.
                 */
                class Comparator : public QIdentityProxyModel {
                   Q_OBJECT
                   bool isLastColumn(const QModelIndex & proxyIndex) const {
                      return proxyIndex.column() == columnCount(proxyIndex.parent()) - 1;
                   }
                   QModelIndex indexInColumn(int column, const QModelIndex & proxyIndex) const {
                      return index(proxyIndex.row(), column, proxyIndex.parent());
                   }
                   /** Compares the two images, returning their difference..
                    * Both images are expanded to the larger of their sizes. Missing data is filled with
                    * transparent pixels. The images can be in any format. The difference is in ARGB32. */
                   QImage compare(const QImage & left, const QImage & right) const {
                      QImage delta(left.size().expandedTo(right.size()), QImage::Format_ARGB32);
                      delta.fill(Qt::transparent);
                      QPainter p(&delta);
                      p.setRenderHint(QPainter::Antialiasing);
                      p.drawImage(0, 0, left);
                      p.setCompositionMode(QPainter::CompositionMode_Difference);
                      p.drawImage(0, 0, right);
                      return delta;
                   }
                public:
                   Comparator(QObject * parent = 0) : QIdentityProxyModel(parent) {}
                   QModelIndex index(int row, int column, const QModelIndex &parent) const Q_DECL_OVERRIDE {
                      if (column != columnCount(parent) - 1)
                         return QIdentityProxyModel::index(row, column, parent);
                      return createIndex(row, column, parent.internalPointer());
                   }
                   int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE {
                      return sourceModel()->columnCount(mapToSource(parent)) + 1;
                   }
                   QVariant data(const QModelIndex &proxyIndex, int role) const Q_DECL_OVERRIDE {
                      if (isLastColumn(proxyIndex)) {
                         QVariant left = data(indexInColumn(0, proxyIndex), role);
                         QVariant right = data(indexInColumn(1, proxyIndex), role);
                         if (!left.canConvert<QImage>() || !right.canConvert<QImage>()) return QVariant();
                         return QVariant::fromValue(compare(left.value<QImage>(), right.value<QImage>()));
                      }
                      return QAbstractProxyModel::data(proxyIndex, role);
                   }
                };
                
                QImage sector(qreal diameter, qreal size, qreal start, qreal end, const QColor & color)
                {
                   QImage image(size, size, QImage::Format_ARGB32_Premultiplied);
                   image.fill(Qt::transparent);
                   QPainter p(&image);
                   p.setRenderHint(QPainter::Antialiasing);
                   p.setPen(Qt::NoPen);
                   p.setBrush(color);
                   p.drawPie(QRectF(size-diameter, size-diameter, diameter, diameter),
                             qRound(start*16), qRound((end-start)*16));
                   return image;
                }
                
                QStandardItem * imageItem(const QImage & image) {
                   QScopedPointer<QStandardItem> item(new QStandardItem);
                   item->setEditable(false);
                   item->setSelectable(false);
                   item->setData(QVariant::fromValue(image), Qt::DecorationRole);
                   item->setSizeHint(image.size());
                   return item.take();
                }
                
                typedef QList<QStandardItem*> QStandardItemList;
                
                int main(int argc, char *argv[])
                {
                   QApplication a(argc, argv);
                   QStandardItemModel images;
                   Comparator comparator;
                   QTableView view;
                   comparator.setSourceModel(&images);
                   view.setModel(&comparator);
                
                   images.appendRow(QStandardItemList()
                                    << imageItem(sector(150, 160, 30, 100, Qt::red))
                                    << imageItem(sector(150, 160, 60, 120, Qt::blue)));
                   images.appendRow(QStandardItemList()
                                    << imageItem(sector(40, 45, 0, 180, Qt::darkCyan))
                                    << imageItem(sector(40, 45, 180, 360, Qt::cyan)));
                
                   view.resizeColumnsToContents();
                   view.resizeRowsToContents();
                   view.adjustSize();
                   view.show();
                
                   return a.exec();
                }
                
                #include "main.moc"
                

                這篇關于Qt 模型-視圖-控制器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                read input files, fastest way possible?(讀取輸入文件,最快的方法?)
                The easiest way to read formatted input in C++?(在 C++ 中讀取格式化輸入的最簡單方法?)
                Reading from .txt file into two dimensional array in c++(從 .txt 文件讀取到 C++ 中的二維數組)
                How to simulate a key press in C++(如何在 C++ 中模擬按鍵按下)
                Why doesn#39;t getline(cin, var) after cin.ignore() read the first character of the string?(為什么在 cin.ignore() 之后沒有 getline(cin, var) 讀取字符串的第一個字符?)
                What is the cin analougus of scanf formatted input?(scanf 格式輸入的 cin 類比是什么?)

                <legend id='obPKh'><style id='obPKh'><dir id='obPKh'><q id='obPKh'></q></dir></style></legend>

                    <small id='obPKh'></small><noframes id='obPKh'>

                      <tfoot id='obPKh'></tfoot>
                      <i id='obPKh'><tr id='obPKh'><dt id='obPKh'><q id='obPKh'><span id='obPKh'><b id='obPKh'><form id='obPKh'><ins id='obPKh'></ins><ul id='obPKh'></ul><sub id='obPKh'></sub></form><legend id='obPKh'></legend><bdo id='obPKh'><pre id='obPKh'><center id='obPKh'></center></pre></bdo></b><th id='obPKh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='obPKh'><tfoot id='obPKh'></tfoot><dl id='obPKh'><fieldset id='obPKh'></fieldset></dl></div>
                        <bdo id='obPKh'></bdo><ul id='obPKh'></ul>
                          <tbody id='obPKh'></tbody>

                        1. 主站蜘蛛池模板: 神马九九| 正在播放亚洲 | 免费激情av | 欧洲一区二区在线 | 久久久久久国产精品mv | 午夜精品一区二区三区在线观看 | 免费的色网站 | 中文在线a在线 | 欧美爱爱视频网站 | 久久精品网 | 亚洲高清视频一区二区 | 欧美日韩国产精品激情在线播放 | 日韩综合在线视频 | 国产精品一区二区av | 午夜影院黄 | 久久久久成人精品免费播放动漫 | 久久精品国产久精国产 | 男女啪啪高潮无遮挡免费动态 | 日韩一级不卡 | 一区精品在线观看 | 久久国产高清 | 久久久久久久国产 | 日韩欧美高清dvd碟片 | 日韩字幕一区 | 一级片av | caoporn国产精品免费公开 | 天天操天天干天天透 | 欧美一级在线观看 | 中文字幕伊人 | 亚洲综合色视频在线观看 | 中文字幕视频网 | 天天影视网天天综合色在线播放 | 成人av一区 | 精品国产欧美一区二区三区成人 | 国产一区二区三区在线 | 日韩欧美一区二区三区免费观看 | 日本 欧美 三级 高清 视频 | 91免费观看国产 | 欧美一级淫片007 | 日韩日韩日韩日韩日韩日韩日韩 | 精品一区国产 |