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. [Solved} Qt5 and QVariant

[Solved} Qt5 and QVariant

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 5.7k Views
  • 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 9 Jan 2013, 17:01 last edited by
    #1

    These codes are working fine with previous Qt version.
    But, Qt5 gives me this error :
    Qt5.0.0/5.0.0/gcc_64/include/QtCore/qvariant.h:472: error: 'QVariant::QVariant(Qt::PenStyle)' is private
    What is the correct way for these codes?
    @
    ui->comboBox_Pen->addItem(tr("SolidLine"),static_cast<int>(Qt::SolidLine));
    @
    @
    ui->comboBox_Pen->addItem(tr("DashLine"),Qt::DashLine);
    ui->comboBox_Pen->addItem(tr("DotLine"),Qt::DotLine);
    ui->comboBox_Pen->addItem(tr("DashDotLine"),Qt::DashDotLine);
    ui->comboBox_Pen->addItem(tr("DashDotDotLine"),Qt::DashDotDotLine);
    ui->comboBox_Pen->addItem(tr("CustomDashLine"),Qt::CustomDashLine);
    @

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on 9 Jan 2013, 18:03 last edited by
      #2

      [quote]- QVariant:

      • Inconsistent constructor taking Qt::GlobalColor and producing QVariant(QColor)
        instance was removed. Code constructing such variants can be migrated by
        explicitly calling QColor constructor. For example from "QVariant(Qt::red)"
        to "QVariant(QColor(Qt::red))"
      • Similarly, implicit creation of QVariants from enum values Qt::BrushStyle,
        Qt::PenStyle, and Qt::CursorShape have been removed. Create objects explicitly
        or use static_cast<int>(Qt::SolidLine) to create a QVariant of type int with
        the same value as the enum.[/quote]Use <code>QVariant::fromValueQt::PenStyle(Qt::DotLine)</code> and <code>Q_DECLARE_METATYPE(Qt::PenStyle)</code> or <code>static_cast<int>(Qt::DotLine)</code> instead.
      1 Reply Last reply
      0

      1/2

      9 Jan 2013, 17:01

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved