The problem is that enums are a bit of a tricky type and Qt 5 seems to have removed some specific magic for these enums in question. The base template constructor for QVariant is defined as private as to enforce that QVariants can only be constructed with types they really can handle.
The first solution proposed in the docs is to instantiate an object because it is easier to hold a "normal" type in a QVariant than an enum. QColor, QPen etc. are all QObjects so the general logic to hold them in a QVariant works for them; it doesn't work for Qt::PenStyle.
The second solution then is the typical C-style solution people use when dealing with enums. As an enum is stored as an int, you can always explicitely cast to int (and C sometimes also does this implicitely, where C++ doesn't, afaik). So what is effectively stored in the QVariant is an int and you, the programmer are the only one that knows in reality it is a Qt::PenStyle.
While the first solution is slightly less efficient (thinking of storing thousands of QPen objects instead of QPenStyles/ints), it might be the cleaner one, as the semantics (the QVariant holds a pen you can draw with) are preserved.
If this doesn't work for you:
int getPenStyle() {return (int)penStyle;}
or
QPen getPenStyle() {return QPen(penStyle);}
then please go ahead and post a self-contained example so we can further discuss.