1

I have a simple type declared as

typedef uint64_t Hash;

How can I use this type for the Qt signal/slot structure?

manatttta
  • 3,054
  • 4
  • 34
  • 72
  • use qt5 signal/slot syntax – user3528438 Mar 24 '17 at 14:42
  • @user3528438 can't, because my type is not a QMetaType or something like it – manatttta Mar 24 '17 at 14:47
  • You care declare custom QMetaTypes: http://doc.qt.io/qt-5/custom-types.html – Ervin Szilagyi Mar 24 '17 at 14:52
  • 1
    @ErvinSzilagyi I think it should not be needed because this is a simple type – manatttta Mar 24 '17 at 14:56
  • 2
    The problem is solved here. Summery: use new syntax to get around typedef, use `Q_DECLARE_METATYPE` and `qRegisterMetaType` to pass custom object through signal/slot, be careful of quirks of namespaces. http://stackoverflow.com/questions/21119397/emitting-signals-with-custom-types-does-not-work – user3528438 Mar 24 '17 at 15:12
  • As it was written already, you need to declare and register a metatype. You can also find some useful reading here: http://doc.qt.io/qt-4.8/qt-tools-customtypesending-example.html – ni1ight Mar 24 '17 at 15:17

1 Answers1

2

Since your typedef is of a fundamental type, there is nothing you have to do to use it for signals and slots (even queued connections work, although those break with the »old« string-based connect syntax).

In my tests (with Qt 5.8) I also didn’t have the issue described in this question.

If you use an older Qt5 version which still exhibits this, use the new connect syntax (without the SIGNAL and SLOT keywords).

Community
  • 1
  • 1
Darklighter
  • 2,082
  • 1
  • 16
  • 21