• 94阅读
  • 0回复

关于在类体内实现函数的错误 [复制链接]

上一主题 下一主题
离线lsyzsl
 

只看楼主 倒序阅读 楼主  发表于: 08-03

class NoFocusFrameDelegate : public QStyledItemDelegate
{
public:
    NoFocusFrameDelegate(QObject *parent) :QStyledItemDelegate(parent)
    {

    }

    void NoFocusFrameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    {
        QStyleOptionViewItem itemOption(option); // remove the focus state
        if (itemOption.state & QStyle::State_HasFocus)
        {
            itemOption.state ^= QStyle::State_HasFocus;
        }
        QStyledItemDelegate::paint(painter, itemOption, index);
    }
};

红色行会报错:error: extra qualification 'NoFocusFrameDelegate::' on member 'paint' [-fpermissive]
     void NoFocusFrameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const

解决方法是去掉
NoFocusFrameDelegate::


快速回复
限100 字节
 
上一个 下一个