summaryrefslogtreecommitdiffstats
path: root/ui/qt/utils/variant_pointer.h
blob: 7a95a94c56c2870de35ce253647031cc72d729d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/** @file
 *
 * Range routines
 *
 * Roland Knall <rknall@gmail.com>
  *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef UI_QT_VARIANT_POINTER_H_
#define UI_QT_VARIANT_POINTER_H_

#include <QVariant>

template <typename T> class VariantPointer
{

public:
    static T* asPtr(QVariant v)
    {
        return  (T *) v.value<void *>();
    }

    static QVariant asQVariant(T* ptr)
    {
        return QVariant::fromValue((void *) ptr);
    }
};

#endif /* UI_QT_VARIANT_POINTER_H_ */