[][src]Function opencv::highgui::create_button

pub fn create_button(
    bar_name: &str,
    on_change: Option<Box<ButtonCallback>>,
    _type: i32,
    initial_button_state: bool
) -> Result<i32>

Attaches a button to the control panel.

The function createButton attaches a button to the control panel. Each button is added to a buttonbar to the right of the last button. A new buttonbar is created if nothing was attached to the control panel before, or if the last element attached to the control panel was a trackbar or if the QT_NEW_BUTTONBAR flag is added to the type.

See below various examples of the cv::createButton function call: :

This example is not tested
createButton("",callbackButton);//create a push button "button 0", that will call callbackButton.
createButton("button2",callbackButton,NULL,QT_CHECKBOX,0);
createButton("button3",callbackButton,&value);
createButton("button5",callbackButton1,NULL,QT_RADIOBOX);
createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON,1);
createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON|QT_NEW_BUTTONBAR);// create a push button in a new row

Parameters

  • bar_name: Name of the button.
  • on_change: Pointer to the function to be called every time the button changes its state. This function should be prototyped as void Foo(int state,*void); . state is the current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
  • userdata: Pointer passed to the callback function.
  • type: Optional type of the button. Available types are: (cv::QtButtonTypes)
  • initial_button_state: Default state of the button. Use for checkbox and radiobox. Its value could be 0 or 1. (Optional)

C++ default parameters

  • userdata: 0
  • _type: QT_PUSH_BUTTON
  • initial_button_state: false