Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Blank space in QComboBox

[Solved] Blank space in QComboBox

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.6k Views
  • 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 Offline
    H Offline
    Hareen Laks
    wrote on 19 Apr 2013, 08:58 last edited by
    #1

    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
    0
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 19 Apr 2013, 09:01 last edited by
      #2

      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
      0
      • H Offline
        H Offline
        Hareen Laks
        wrote on 19 Apr 2013, 10:56 last edited by
        #3

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

        1/3

        19 Apr 2013, 08:58

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved