Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] Blank space in QComboBox



  • I'm adding the items to the QComboBox via SQL query. Just as below.

    while (query.next())
    {
    ui->comboBox_Version->addItem(query.value(0).toString());
    }

    It is successful.

    But the problem is when initially load the window, there is a blank space on top of the items of the QComboBox. And it may cause user to select blank space.

    How I avoid that?

    Thanks in advance..

    P.S. I'm new to Qt. Sometimes this may be a stupid question. :)


  • Moderators

    you need to select an item after you've filled it up.



  • @ raven-worx,

    Thank you very much for the reply.

    This is due to I read the saved property when loading the Window. Because it is null in the initial state it passes -1 as selected index. And QComboBox display it as a blank space.

    So as your answer I set the default value for the property. Now it is working fine.

    Thanks again...


Log in to reply