zimang
8th December 2010, 08:25
Hi guys:
I want ot have a IP address editor , and use the Key_Left and Key_Right control the text selection between dots. Now, I set the editor like this:
setInputMaks("000.000.000.000");
.....
case Qt::Key_Left:
if (m_selected >= 0 )
{
this->setSelection(m_selected, 3);
if (m_selected > 3)
m_selected -= 4;
}
break;
case Qt::Key_Right:
if (m_selected <= 12)
{
this->setSelection(m_selected, 3);
if (m_selected < 12)
m_selected += 4;
}
break;
...
It works when the input liks 192.168.1.112, but when the input is less than 9 chars (as 192.168.1.1), the Key_Right. It means I will never input the IP address like 192.168.0.XXX or else chars less than 9.
So, is there any way to resolve this problem: the Key_Right or Key_Left selects the area between two idos.
Added after 26 minutes:
It works on X11, but can't be in embelded.
:mad::mad::mad:
I want ot have a IP address editor , and use the Key_Left and Key_Right control the text selection between dots. Now, I set the editor like this:
setInputMaks("000.000.000.000");
.....
case Qt::Key_Left:
if (m_selected >= 0 )
{
this->setSelection(m_selected, 3);
if (m_selected > 3)
m_selected -= 4;
}
break;
case Qt::Key_Right:
if (m_selected <= 12)
{
this->setSelection(m_selected, 3);
if (m_selected < 12)
m_selected += 4;
}
break;
...
It works when the input liks 192.168.1.112, but when the input is less than 9 chars (as 192.168.1.1), the Key_Right. It means I will never input the IP address like 192.168.0.XXX or else chars less than 9.
So, is there any way to resolve this problem: the Key_Right or Key_Left selects the area between two idos.
Added after 26 minutes:
It works on X11, but can't be in embelded.
:mad::mad::mad: