Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5 and qVariantValue?
Forum Updated to NodeBB v4.3 + New Features

Qt5 and qVariantValue?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.7k 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
    • T Offline
      T Offline
      tilsitt
      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 Extensions
        • Unsolved