Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5 and qVariantValue?
Qt 6.12 LTS is out! See what's new in the release blog

Qt5 and qVariantValue?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IanBorn
    wrote on last edited by
    #1

    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;
    }
    ...
    }
    @

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi,

      does the following work?

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

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

      1 Reply Last reply
      0
      • I Offline
        I Offline
        IanBorn
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved