If you are are calling complete() in constructor then you can notice that the popup actually appears for a moment just before the main window. Best solution would be probably this:
action
->setShortcut
(QKeySequence(Qt
::CTRL + Qt
::Key_Space));
ui->lineEdit->addAction(action);
connect(action, SIGNAL(triggered()), completer, SLOT(complete()));
QAction* action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Space));
ui->lineEdit->addAction(action);
connect(action, SIGNAL(triggered()), completer, SLOT(complete()));
To copy to clipboard, switch view to plain text mode
But if you really want the popup to appear together with main window then this could do the trick:
...
QTimer::singleShot(250,
this,
SLOT(func
()));
}
void MainWindow::func()
{
completer->complete();
}
...
QTimer::singleShot(250, this, SLOT(func()));
}
void MainWindow::func()
{
completer->complete();
}
To copy to clipboard, switch view to plain text mode
Bookmarks