I'm not able to implement a check...
The first thing I've tried is this
int PaletteTableModel
::columnCount(const QModelIndex &index
) const {
if(index.row() > (m_colors.count() - 1))
return 0;
if(index.column() > (m_colors.at(index.row()).count()) - 1)
return 0;
return m_colors.at(index.row()).count();
}
int PaletteTableModel::columnCount(const QModelIndex &index) const
{
if(index.row() > (m_colors.count() - 1))
return 0;
if(index.column() > (m_colors.at(index.row()).count()) - 1)
return 0;
return m_colors.at(index.row()).count();
}
To copy to clipboard, switch view to plain text mode
But the function is getting called with index.row() = -1. Why gets the function called with index.row() = -1?
So I extended the function
int PaletteTableModel
::columnCount(const QModelIndex &index
) const {
if(index.row() < 0)
return 0;
if(index.row() > (m_colors.count() - 1))
return 0;
if(index.column() > (m_colors.at(index.row()).count()) - 1)
return 0;
return m_colors.at(index.row()).count();
}
int PaletteTableModel::columnCount(const QModelIndex &index) const
{
if(index.row() < 0)
return 0;
if(index.row() > (m_colors.count() - 1))
return 0;
if(index.column() > (m_colors.at(index.row()).count()) - 1)
return 0;
return m_colors.at(index.row()).count();
}
To copy to clipboard, switch view to plain text mode
Now it works with an empty list.
But when I try to fill the two dimensional list and pass it like this
QList<QColor> list;
m_list << list << list << list;
m_model = new PaletteTableModel(m_list, this);
QList<QColor> list;
list << QColor(Qt::red) << QColor(Qt::green) << QColor(Qt::blue);
m_list << list << list << list;
m_model = new PaletteTableModel(m_list, this);
To copy to clipboard, switch view to plain text mode
I still get the same error. What am I doing wrong?
Bookmarks