Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not convert from inherited class "No suitable constructor exists to convert from "QStandardItem *" to "FolderItem""
    primarykey
    data
    text
    <p>Hi I am in the process of trying to impliment subclass of the qt library supplied QStandardItemModel and QStandardItem to display items in a Qtreeview. Everything seems to work fine except for when I try to retrieve the selected object from the tree view and use it as a parent object to add children too. The issue is that the selected object retrieves as the inherited type "QStandardItem" and not my subtype "FolderItem":</p> <pre><code>FolderItem KSLgui::GetSelectedFolder() { QItemSelectionModel * model = ui.folderView-&gt;selectionModel(); QModelIndexList indexes = model-&gt;selectedIndexes(); return (FolderItem)folderModel.itemFromIndex(indexes.first()); } </code></pre> <p>I get an error telling me that no sutible constructor exists to convert from the two types. I have overloaded all the constructors for both types when making my subtypes and tried to make a new constructor that excepts QStandardItem as a parameter which appears to fix the error but doesn't function properly as it only returns an empty object and not the selected object:</p> <pre><code>FolderItem::FolderItem() : QStandardItem() { } FolderItem::FolderItem(const std::string &amp; text) : QStandardItem(QString::fromStdString(text)) { } FolderItem::FolderItem(const QIcon &amp; icon, const QString &amp; text) : QStandardItem(icon, text) { } FolderItem::FolderItem( int rows, int columns) : QStandardItem(rows, columns) { } /* returns empty FolderItem::FolderItem(QStandardItem * stanitem) { } */ FolderItem::~FolderItem() { } int FolderItem::type() const { return 1001; } FolderStructureModel::FolderStructureModel(QObject *parent) : QStandardItemModel(parent) { } </code></pre> <p>I have included what I beleive to be the significant code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload