[Solved} Qt5 and QVariant



  • 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);
    @



  • [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.

Log in to reply
 

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