Qt5 and qVariantValue?



  • Since Qt5 doesn't have qVariantValue, is there anyway to make these codes working?

    @
    void test::penColorChanged()
    {
    penAction = qobject_cast<QAction *>(sender());
    ui->toolButton_GPenColor->setIcon(createColorIcon(qVariantValue<QColor>(penAction->data())));
    penButtonTriggered();

    }
    void test::penButtonTriggered()
    {
    int r,g,b,a;
    pen_color=qVariantValue<QColor>(penAction->data());
    if (pen_color==Qt::darkGray)
    {
    QColor newColor = QColorDialog::getColor(pen_color);
    pen_color=newColor;
    }
    ...
    }
    @



  • Hi,

    does the following work?

    @
    ui->toolButton_GPenColor->setIcon(createColorIcon(penAction->data().value<QColor>()));
    @

    @
    pen_color=penAction->data().value<QColor>();
    @



  • Thank, It compiles. I have some more issues to be fixed before it can run.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.