• qt在tableview中绘制图片


    void ItemModelDeletage::paint(QPainter *painter, const QStyleOptionViewItem &option,
                                               const QModelIndex &index) const
    {
        QStyleOptionViewItem viewOption(option);
        initStyleOption(&viewOption, index);
        if (option.state.testFlag(QStyle::State_HasFocus))
            viewOption.state = viewOption.state ^ QStyle::State_HasFocus;
    
    
    ItemModelDeletage::paint(painter, viewOption, index);
        if(index.column() == AllowTradeTime::Operator)
        {
            QStyleOptionButton buttonStyle;
                    buttonStyle.rect = option.rect.adjusted(0, 0, 0, 0);
                    buttonStyle.text = "X";
                    buttonStyle.state = QStyle::State_Enabled;
    
    
            QPushButton button;
            buttonStyle.initFrom(&button);
            button.setFlat(true);
            button.setStyleSheet("QPushButton{ border-image:url(res/skin/default/images/dockwidget/dock_close.png) no-repeat;}");
            //QApplication::style()->drawControl(QStyle::CE_PushButton, &buttonStyle, painter);
            //painter->drawText(option.rect,Qt::AlignJustify | Qt::AlignVCenter | Qt::AlignHCenter,"X");
            QImage image;
            bool re= image.load("res\skins\default\images\dockwidget\time_delete.png");
            int sx =-45;
            int sy = -10;
            int sw = 80;
            int sh = 35;
            painter->drawImage(option.rect.x(),option.rect.y(),image,sx, sy,sw,sh,Qt::AutoColor);
        }
    }
  • 相关阅读:
    Java Web总结一反射、单例模式
    Android中Log的管理
    改进边的导航
    当前效果
    understand一些功能
    maya 专家模式
    改进的共轭梯度法
    selenium TestNG 依赖和忽略测试
    selenium TestNG基本注释和属性
    JAVA 批量执行测试用例
  • 原文地址:https://www.cnblogs.com/tianmochou/p/9259022.html
Copyright © 2020-2023  润新知