• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 70, 文章 - 0, 評論 - 9, 引用 - 0
            數據加載中……

            QTableView, QTableWidget 用法整理

            1  根據數據內容設定寬
                resizeColumnToContents, resizeColumnsToContents
            void QTableView::resizeColumnToContents ( int column ) [slot]
            void QTableView::resizeColumnsToContents () [slot]

            2  去掉網格 setShowGrid

            3  委托
                需要在單元格里進行特別處理,如需要QLineEdit, QComcoBox等時,需要用委托機制來實現。
                委托需要實現的幾個函數
                QTableView, QTableWidget對其數據進行委托:setItemDelegate, setItemDelegateForColumn, setItemDelegateForRow
                委托時QItemDelegate需要重新實現的函數:createEditor(創建控件),setEditorData(設置值),setModelData,updateEditorGeometry(設置大小)
                部分實現代碼示例
            QWidget *LLineEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
            {
                QLineEdit 
            *editor = new CompleteLineEdit(parent);
                
            return editor;
            }


            void LLineEditDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
            {
                QString value 
            = index.model()->data(index, Qt::EditRole).toString();
                QLineEdit 
            *lineEdit = static_cast<QLineEdit *>(editor);
                lineEdit
            ->setText(value);
            }


            void LLineEditDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
            {
                QLineEdit 
            *lineEdit = static_cast<QLineEdit *>(editor);
                QString value 
            = lineEdit->text();
                model
            ->setData(index, value, Qt::EditRole);
            }


            void LLineEditDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
            {
                editor
            ->setGeometry(option.rect);
            }

            posted on 2011-03-24 09:58 seahouse 閱讀(5603) 評論(0)  編輯 收藏 引用 所屬分類: Qt

            91精品国产91久久综合| 国产一区二区三区久久精品| 性高朝久久久久久久久久| 久久综合伊人77777| 色青青草原桃花久久综合| 91精品国产乱码久久久久久| 一本一道久久精品综合| 亚洲v国产v天堂a无码久久| 久久亚洲欧美国产精品| 亚洲性久久久影院| 色综合久久无码五十路人妻| 大美女久久久久久j久久| 99精品久久精品一区二区| 久久国产高清字幕中文| 久久青青色综合| 久久99精品久久久久久齐齐| 亚洲中文字幕无码久久2017| 久久九九久精品国产免费直播| 国产成人综合久久精品红| 国内精品伊人久久久久网站| 高清免费久久午夜精品| 伊人色综合久久天天人手人婷| 精品久久久久国产免费| 精品一区二区久久| 国产人久久人人人人爽| 囯产极品美女高潮无套久久久| 久久精品不卡| 久久www免费人成精品香蕉| a高清免费毛片久久| 亚洲精品无码久久久久sm| 国产精品中文久久久久久久| 久久久无码精品午夜| 久久99亚洲综合精品首页| 久久久久综合中文字幕 | 国内精品久久久久国产盗摄| 久久亚洲精品中文字幕| 国产激情久久久久久熟女老人| 久久精品一区二区三区AV| 一97日本道伊人久久综合影院| 色综合久久88色综合天天 | 欧美激情精品久久久久久久|