Suggestions- Publishing data on a topic using Qt Slider
Hello All,
I am new to ROS, I need help regarding implementation of qt-slider in ros.
Can any one help me or give suggestions, thanks in advance.
I have qt source files: Please have a look:
MainWindow::MainWindow()
{
slider = new QSlider(Qt::Horizontal);
slider->setMinimum(0);
slider->setMaximum(100);
lineEdit = new QLineEdit();
QObject::connect(slider, SIGNAL(valueChanged(int)),
this, SLOT(onValueChanged(int)));
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(slider);
layout->addWidget(lineEdit);
QWidget *wrapper = new QWidget();
wrapper->setLayout(layout);
setCentralWidget(wrapper);
}
MainWindow::~MainWindow()
{
}
void MainWindow::onValueChanged(int value)
{
int pos = slider->sliderPosition();
QByteArray convertedValue = QByteArray::number(pos,16);
QString m = QString(convertedValue);
m= "0x"+m;
QString id,len, canmsg;
id="0x01 ";
len="0x01 ";
canmsg=id+len+m;
lineEdit->setText(canmsg);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow mainWindow;
mainWindow.show();
return app.exec();
}
Can any one help me to publish this message(i mean 'canmsg') on topic(any). As discussed in qt ros, I made changes in cmakelist.txt. Thanks for reading.
Please edit your question and include what you have tried yourself, what happened and why that didn't work. Otherwise we run the risk of suggesting things that you have already tried but didn't work for some reason.
Do you have a QNode class as well ? That's where you have to define and use your ROS publisher.