• 大小: 47KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-01-03
  • 语言: 其他
  • 标签: QTableView  

资源简介

QTableView 中单元格添加控件的实例代码(含combobox)QTableView 中单元格添加控件的实例代码(含combobox)QTableView 中单元格添加控件的实例代码(含combobox)

资源截图

代码片段和文件信息

#include “combodelegate.h“

ComboDelegate::ComboDelegate(Qobject *parent)
    : QItemDelegate(parent)
{
}

QWidget *ComboDelegate::createEditor(QWidget *parent
    const QstyleOptionViewItem &/* option */
    const QModelIndex &/* index */) const
{
    QComboBox *editor = new QComboBox(parent);
    editor->addItem(QString::fromLocal8Bit(“工人“));
    editor->addItem(QString::fromLocal8Bit(“农民“));
    editor->addItem(QString::fromLocal8Bit(“医生“));
    editor->addItem(QString::fromLocal8Bit(“律师“));
    editor->addItem(QString::fromLocal8Bit(“军人“));

    editor->installEventFilter(const_cast(this));

    return editor;
}

void ComboDelegate::setEditorData(QWidget *editor
                                     const QModelIndex &index) const
{
    QStri

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1457  2008-04-26 17:43  delegate\delegate\combodelegate.cpp

     文件        669  2008-04-26 17:48  delegate\delegate\combodelegate.h

     文件        106  2008-04-26 17:29  delegate\delegate\data.tab

     文件       1332  2008-04-26 17:01  delegate\delegate\datedelegate.cpp

     文件        665  2008-04-26 16:39  delegate\delegate\datedelegate.h

     文件      40487  2008-05-10 19:02  delegate\delegate\delegate

     文件      41984  2008-05-10 18:58  delegate\delegate\delegate.exe

     文件        436  2008-05-10 19:02  delegate\delegate\delegate.pro

     文件      13565  2010-11-19 11:17  delegate\delegate\delegate.pro.user

     文件        439  2008-04-26 17:59  delegate\delegate\delegate_zh.qm

     文件        601  2008-04-26 17:59  delegate\delegate\delegate_zh.ts

     文件       2272  2008-04-26 17:59  delegate\delegate\main.cpp

     文件       9200  2008-05-10 19:02  delegate\delegate\Makefile

     文件       6717  2008-05-10 19:00  delegate\delegate\Makefile.Release

     文件       1173  2008-04-27 13:10  delegate\delegate\spindelegate.cpp

     文件        673  2008-04-27 13:10  delegate\delegate\spindelegate.h

    ..A..H.     15360  2008-04-27 09:54  delegate\delegate\Thumbs.db

     目录          0  2010-11-19 11:26  delegate\delegate

     目录          0  2010-11-19 11:26  delegate

----------- ---------  ---------- -----  ----

               137136                    19


评论

共有 条评论