#include "Dialog.h" #include #include class DataTableModel : public QAbstractTableModel { public: DataTableModel( QObject* parent ); int rowCount( const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE; int columnCount( const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE; QString m_text; }; DataTableModel::DataTableModel( QObject* parent ) : QAbstractTableModel( parent ) { } QVariant DataTableModel::data( const QModelIndex&, int role ) const { switch ( role ) { case Qt::DisplayRole: case Qt::ToolTipRole: { return QVariant( m_text ); } } return QVariant(); } int DataTableModel::rowCount( const QModelIndex& ) const { return 5; } int DataTableModel::columnCount( const QModelIndex& ) const { return 5; } Dialog::Dialog(QWidget *parent) : QDialog(parent) { setupUi(this); QChar ch = QChar( 0xFFFC ); QString text; text += "x"; text += ch; text += "y"; text += ch; text += "z"; m_lineEdit->setText( text ); DataTableModel* model = new DataTableModel( this ); model->m_text = text; m_tableView->setModel( model ); QFontMetrics fm( font() ); qDebug() << "font=" << font(); qDebug() << "text=" << text; qDebug() << "ch=" << ch; qDebug() << "inFont( ch )=" << fm.inFont( ch ); } Dialog::~Dialog() { }