Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Usage of createTrackbar for QT control panel possible?

Hello,

I would like to use the function "createTrackbar" for creating a trackbar on the QT control panel.

The info about this feature you can find here: http://docs.opencv.org/modules/highgui/doc/qt_new_functions.html

If I use "cvCreateTrackbar" with NULL as window everything works fine but with createTrackbar it ist not working.

Has anybody an idea how to fix this?

This is a working minimal:

#include "opencv2/core/core.hpp"
#include <opencv2/highgui/highgui.hpp>

using namespace cv;    

const int slider_1_max  = 255;
      int slider_1 = 0;
const int slider_2_max  = 255;
      int slider_2 = 0;

Mat test;


void on_trackbar_1(int pos)
{
pos=slider_1;    
}

void on_trackbar_2(int pos, void*)
{    
}


int main ()
{
    namedWindow("Test");

     cvCreateTrackbar("One",NULL, &slider_1,slider_1_max, on_trackbar_1);

     //Not working:
     //createTrackbar("Two",NULL, &slider_2,slider_2_max, on_trackbar_2);


 while (char(waitKey(1)) != 'q'){}
 return 0;
}

Thank you very much :-)