Skip to content

Instantly share code, notes, and snippets.

@iiey
Created May 28, 2019 09:15
Show Gist options
  • Save iiey/936af791253faff2e5202ddde2ea59de to your computer and use it in GitHub Desktop.
Save iiey/936af791253faff2e5202ddde2ea59de to your computer and use it in GitHub Desktop.
handle static method createTrackbar of opencv
class A
{
public:
void handleTrackbar(int value)
{
// real work here, can use 'this'
}
//workaround not to declare static var used inside
static void onTrackbar(int value, void* ptr)
{
auto obj = static_cast<A*>(ptr);
obj->handleTrackbar(value);
}
};
createTrackbar(trck_name,
wnd_name,
&setting,
(int)out_max,
A::onTrackbar, //now a static member
this); //this one must be given
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment