查看完整版本: [-- 关于在类体内实现函数的错误 --]

QTCN开发网 -> Qt基础编程 -> 关于在类体内实现函数的错误 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

lsyzsl 2017-08-03 10:32

关于在类体内实现函数的错误


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::




查看完整版本: [-- 关于在类体内实现函数的错误 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled