December
9th September 2006, 11:44
Hi All,
I am fairly new QT, having slowly moved from Windows to Linux, I am now re-writing one of my apps from scratch in QT with KDevelop.
I have writing a program that controls stage / club lighting, and uses a MIDI controller as a tactile interface. In the main I have 8 QSliders that correspond to 8 physical sliders on the MIDI controller. I have a QThread that receives MIDI and then passes a QCustomEvent to the main window for appropriate MIDI messages.
When I move a fader on the MIDI controller, my main form is correctly receiving the messages, but here I have run into a problem. When I use the values that the Event is passing to update the position of the slider.. things are pretty bad. The sliders seem to flicker a lot, and lag behind the physical faders by a fair bit.
Thebit of code that updates the QSlider:
if ( e->type() == 2001 ) { // It must be a DataEvent
d_e = (MyDataEvent *) e;
if( d_e->param() > 80 && d_e->param() < 89 ) { // Playback Slider
slider = lPlaySliders.at( d_e->param() - 80 );
if(slider->value() != d_e->value() )
slider->setValue( d_e->value() );
}
}
e is the event, param and value are integers from the MIDI messages. The range of value and therefor the QSliders is 0 to 127 for now. lPlaySliders is an array containing all the 'playback' sliders in the form.
I though it might be the Event mechanism not keeping up (even though the MIDI messages are not coming in at any crazy rate), but having the Event Handler update the text on a QPushButton with the value instead of moving a slider works as it should.. the number keeps up well with the MIDI.
Anyone have any ideas what could be wrong here? Is QSlider prone to update problems.. is there another component I could use instead?
I am fairly new QT, having slowly moved from Windows to Linux, I am now re-writing one of my apps from scratch in QT with KDevelop.
I have writing a program that controls stage / club lighting, and uses a MIDI controller as a tactile interface. In the main I have 8 QSliders that correspond to 8 physical sliders on the MIDI controller. I have a QThread that receives MIDI and then passes a QCustomEvent to the main window for appropriate MIDI messages.
When I move a fader on the MIDI controller, my main form is correctly receiving the messages, but here I have run into a problem. When I use the values that the Event is passing to update the position of the slider.. things are pretty bad. The sliders seem to flicker a lot, and lag behind the physical faders by a fair bit.
Thebit of code that updates the QSlider:
if ( e->type() == 2001 ) { // It must be a DataEvent
d_e = (MyDataEvent *) e;
if( d_e->param() > 80 && d_e->param() < 89 ) { // Playback Slider
slider = lPlaySliders.at( d_e->param() - 80 );
if(slider->value() != d_e->value() )
slider->setValue( d_e->value() );
}
}
e is the event, param and value are integers from the MIDI messages. The range of value and therefor the QSliders is 0 to 127 for now. lPlaySliders is an array containing all the 'playback' sliders in the form.
I though it might be the Event mechanism not keeping up (even though the MIDI messages are not coming in at any crazy rate), but having the Event Handler update the text on a QPushButton with the value instead of moving a slider works as it should.. the number keeps up well with the MIDI.
Anyone have any ideas what could be wrong here? Is QSlider prone to update problems.. is there another component I could use instead?