Advertisement
Guest User

Strange case with QStyledItemDelegate::setModelData

a guest
May 4th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. void GuiItemDelegate::setModelData(QWidget* widget, QAbstractItemModel* model, const QModelIndex& index) const
  2. {
  3.     static int string_id = qMetaTypeId<std::string>();
  4.     QByteArray n = widget->metaObject()->userProperty().name();
  5.     QVariant variant = widget->property(n);
  6.    
  7.     std::cout << std::string(widget->metaObject()->userProperty().typeName()) << std::endl;
  8.     if(variant.userType() == QVariant::String && variant.userType() != QMetaType::Float) {
  9.         std::cout << "lolwut" << std::endl;
  10.         model->setData(index, QVariant::fromValue(variant.toString().toStdString()), Qt::EditRole);
  11.     } else {
  12.         QStyledItemDelegate::setModelData(widget, model, index);
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement