Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED =)]ComboBox Qstring but need an int or GLenumb
Hey everyone once again I got a question to ask,
I got a combobox with 10 values:
"Picture of the combobox values here":http://i.imgur.com/lYo9A.jpg
As you can see it's a list of OpenGL primitives that are GLenumb.
I got this function:
@void MainWindow::on_cmbx_primatives_currentIndexChanged(const QString &arg1)
primL = arg1;
This sets the PrimitiveType value in the rendering class but clearly it's just a string and not an integer. Is it possible to set an additional value to a comboxbox argument for example the Text would be as an additional value that I could pass???
"Since you can set comments and other additional values":http://i.imgur.com/jYYrB.jpg
@GL_POINTS : but contain 0x0000@
You can populate your combobox with "this":http://qt-project.org/doc/qt-4.8/qcombobox.html#addItem function:
@void void QComboBox::addItem ( const QString & text, const QVariant & userData = QVariant() )@
userData can be all you want...
Thank you, it seems i am doing something wrong
@ui->cmbx_primatives->addItem(const QString("Test"), const QVariant & userdata = QVariant(const int(0x0000)));@
yep AcerExtensa that worked like a charm =]
but how do I access the integer value from arg1 so I could pass it to the render class?
@void currentIndexChanged ( int index )@
signal instead one with QString.
your slot will be when like this:
@void MainWindow::on_cmbx_primatives_currentIndexChanged(int index)
primL = ui->cmbx_primatives->itemData(index).toInt();
AcerExtensa your magic worker, is it possible to access the name of the index instead of the number.
I tried @QString arg1 = ui->cmbx_primatives->itemText(index).toStdWString();@ but that's wrong
@QString arg1 = ui->cmbx_primatives->itemText(index);@
should be enough... or:
@QString arg1 = ui->cmbx_primatives->currentText();@
it will return text of currently selected item
Yep that worked right away.
Well I removed all the values from the comboxbox in the Qt creator interface and the program crashed.
"The program has unexpectedly finished."
So then I just randomly added an item to the combo box and it worked again. Why's that?
Maybe you're trying to access items or userData before there is any items in combobox? Sounds pretty like that....
Once again AcerExtensa thank very much =] all my problems are now solved!!!
You are welcome! Please add "[SOLVED]" to the topic subject.