Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] Blank space in QComboBox

    General and Desktop
    2
    3
    3144
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Hareen Laks last edited by

      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. :)

      1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators last edited by

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

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • H
          Hareen Laks last edited by

          @ 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...

          1 Reply Last reply Reply Quote 0
          • First post
            Last post