Hi, I've got a class which has function that will run upon instantiation to set various member variables. One of the values in the initialiser list is a QString. This is pretty stupid coding but I haven't figured out a more eloquent way of doing it as of yet but basically, since I'm hard coding this stuff, I'm relying on the fact that I won't have to make any changes and that I don't make mistakes but I digress...
Basically my QString will be something along the lines of a1.
I've already written the code that ?parses? the string for the first letter to do consequent processing and class member variable setting with the use of myString.startsWIth("a"), however I also need to somehow use the second value to set member variables.
{
//Left line select key
if(sVar.startsWith("a"))
{
this->m_iInt = LEFT_ALIGNED;
if(sVar[1].isDigit())
{
this->m_iInt2 = sVar[1];
}
}
}
void MyClass::SetVar(QString sVar)
{
//Left line select key
if(sVar.startsWith("a"))
{
this->m_iInt = LEFT_ALIGNED;
if(sVar[1].isDigit())
{
this->m_iInt2 = sVar[1];
}
else QMessageBox::information(this, "Error", "Error");
}
}
To copy to clipboard, switch view to plain text mode
So the question is... since sVar[2] returns a QCharRef, how do I then set my m_iInt2 value to whatever that string number is?
Bookmarks