I've got a data entry screen on the Qt/Embedded device that has only up/lower/left/right/choose buttons. The screen appears like a calculator having a QLineEdit on the top and some QPushButtons for that amounts. The UDLR buttons move focus round the QPushButtons and choose appends the button's number towards the QLineEdit. This is effective. However, because the QLineEdit does not have focus, the written text entry cursor does not blink. The QLineEdit just does not seem like it is the person receiving the virtual keyboard button presses and that is bad.

Another Qt virtual keyboard implementations that I have seen have no need for their keyboard buttons to achieve focus being that they are touch or mouse operated. Therefore, the QLineEdit can retain focus the whole time. That isn't a choice here. The very best the I have seen to date is manual generation of focus occasions to trick the QLineEdit into convinced that it's focus once the user is actually moving round the virtual keyboard. I'm wishing that there's a far more elegant solution or possibly an additional way to structure the screen's implementation that eliminates this problem. Any ideas?

Because it appears like you do not need the real editing abilities of QLineEdit, change it having a QLabel. You are able to nest it in the frame to really make it seem like an edit box. You'll be able to simulate a blinking cursor utilizing a QTimer that does not need focus to operate.

Start the timer having a 500ms interval as well as in the timer slot, place or remove a '' character such as this:

void MainWindow::slot_timeout()
{
    QString labelText = label->text();    
    if(labelText.right(1) == "|")
    {
        labelText = labelText.left(labelText.size()-1);
    }
    else
    {
        labelText += "|";
    }    
    label->setText(labelText);
}

Whenever your choose button is pressed, place the right character in front from the string to ensure that the blinking cursor stays around the right finish.

void MainWindow::slot_selectClick()
{
    QString labelText = label->text();
    labelText.prepend("x");
    label->setText(labelText);
}

It may be enough to offer the effect you're searching for.