c++ - How to declare Qt::PenStyle in Qt5? -


I am migrating a project from QT 4.x to 5, and a class that has a feature that is :

  Qt :: penstyle penstyle;   

and its related functions:

  Qt :: Penstyle Paenstyle () {return penStyle;}   

There is a compilation error saying that

  error: 'QVariant :: QVariant (Qt :: PenStyle)' Private QVariant (Qt :: PenStyle) Q_DECL_EQ_DELETE; ^ .. \ marssies \ painterbar.cpp: 217: 88: Error: Style within this Reference Line - & gt; SetCurrentIndex (lineStyle -> SearchData (graphic object-> GetPenStyle ())); ^   

Some research has shown me:

QVariant:
* Incompatible Constructor Qt :: GlobalColor and QVariant (QColor) Examples Production of removed. The code that creates such forms can be migrated by calling the QColor constructor explicitly. For example, QVariant (QColor (Qt :: red)) from "QVariant" (Qt :: red)

* Similarly, the built-in QVariants of built-in QV :: BrushStyle, Qt :: PenStyle , And Qt :: CursorShape has been removed. Obviously create objects or use static_cast (Qt :: SolidLine), in which QVariant with the same value as the AQ value.

The question is, how should I declare attribute / function if I can not do QT :: as soon as the penstyle? What does it mean by creating objects clearly? I have tried to do something like a bid, but I did not manage to solve it. I managed to solve other similar errors, but none of them was announcing the features or functions.

Complete error:

  is included in the file .. .. \. \ .. \ Qt5 \ 5.2.1 \ mingw48_32 \ include \ QtCore / qsettings.h: 46: 0, from .. \. \ .. \ .. \ .. \ Qt5 \ 5.2.1 \ Mingw48_32 \ Include \ QtCore / QSettings: 1, from .. \ mararsies \ appcommon.h: 10, from \ mararsies \ painterbar.h: 5, from \ mararsies \ painterbar.cpp: 1: .. \. . \. \. \ .. \ .. \ Qt5 \ 5.2.1 \ mingw48_32 \ include / QtCore / qvariant.h: member function 'zero painterbar :: setgraphic object (GraphicsPrintive *, Painterbar :: FinishModa)' in: .. \ .. \ .. \ .. \ .. \ Qt5 \ 5.2.1 \ mingw48_32 \ include / QtCore / qvariant.h: 482: 5: Error: 'QVariant :: QVariant (Qt :: PenStyle)' private QVariant is QT :: Penstyle) Q_DECL_EQ_DELETE; ^ .. \ marssies \ painterbar.cpp: 217: 88: Error: Style within this Reference Line - & gt; SetCurrentIndex (lineStyle -> SearchData (Graphic Object-> GetPenStyle ()); The problem is that the enums are a bit of a difficult type and looks like QT5;    

The first solution proposed in the docs is to instantiate the object because it is easy to hold a "normal" type in a QVariant from an enum QColor, QPen etc. All QObjects are so general logic to keep them in a QVariant Works for them; It does not work for Qt :: PenStyle.

The second solution is then a special C-style solution that uses when working with Iman. As an enum is stored in an int, you can always be explicitly inserted at int (and also C), it never puts it where C ++ is not, afaik). So what is effectively stored in QVariant is an int and you, the programmer is the only one who really knows that this is a QT :: penstyle.

While the first solution is a little less efficient, stored thousands of QPen objects instead of QPenStyles / ints), this can be cleaner, because the vocabulary (QVariant holds a pen that you can drag).

If this does not work you can:

  int getPenStyle () {return (int) penStyle;}   

or < / P>

  QPen getPenStyle () {Return QPen (penStyle);}   

Then go ahead and post a self-contained example so that we can discuss more.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -