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. QComboBox Entries not placed correctly
Forum Updated to NodeBB v4.3 + New Features

QComboBox Entries not placed correctly

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 892 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MaxDevI
    wrote on last edited by MaxDevI
    #1

    EDIT: Fixed!

    The problem was that I did not instantiate the combo box with its parent.

    I did

    QComboBox *myBox = new QComboBox();
    

    where adding the parent as so...

    QComboBox *myBox = new QComboBox(parent);
    

    completely fixed the problem.
    EDIT^^

    alt text

    My QComboBox starts out correctly as seen in picture #1. I add items to the box, but when displaying the items, they appear too close together as in picture #2.

    I want it to appear normally, as in picture #3. What am I doing wrong?

    One weird thing to note is that it used to appear correctly before I added it to a particular layout.

    Thanks for any help.

    VRoninV 1 Reply Last reply
    0
    • M Offline
      M Offline
      MaxDevI
      wrote on last edited by
      #3

      Fixed!

      The problem was that I did not instantiate the combo box with its parent.

      I did

      QComboBox *myBox = new QComboBox();
      

      where adding the parent as so...

      QComboBox *myBox = new QComboBox(parent);
      

      completely fixed the problem.

      VRoninV 1 Reply Last reply
      1
      • M MaxDevI

        EDIT: Fixed!

        The problem was that I did not instantiate the combo box with its parent.

        I did

        QComboBox *myBox = new QComboBox();
        

        where adding the parent as so...

        QComboBox *myBox = new QComboBox(parent);
        

        completely fixed the problem.
        EDIT^^

        alt text

        My QComboBox starts out correctly as seen in picture #1. I add items to the box, but when displaying the items, they appear too close together as in picture #2.

        I want it to appear normally, as in picture #3. What am I doing wrong?

        One weird thing to note is that it used to appear correctly before I added it to a particular layout.

        Thanks for any help.

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #2

        @MaxDevI said in QComboBox Entries not placed correctly:

        One weird thing to note is that it used to appear correctly before I added it to a particular layout.

        That's a nice clue!

        Could you post the layout code and where you add the combobox to it?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        M 1 Reply Last reply
        0
        • M Offline
          M Offline
          MaxDevI
          wrote on last edited by
          #3

          Fixed!

          The problem was that I did not instantiate the combo box with its parent.

          I did

          QComboBox *myBox = new QComboBox();
          

          where adding the parent as so...

          QComboBox *myBox = new QComboBox(parent);
          

          completely fixed the problem.

          VRoninV 1 Reply Last reply
          1
          • M MaxDevI

            Fixed!

            The problem was that I did not instantiate the combo box with its parent.

            I did

            QComboBox *myBox = new QComboBox();
            

            where adding the parent as so...

            QComboBox *myBox = new QComboBox(parent);
            

            completely fixed the problem.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #4

            @MaxDevI When you add a widget to a layout it should reparent it, if you are using a custom layout I'd consider checking its internal handling of parent/child

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            1
            • VRoninV VRonin

              @MaxDevI said in QComboBox Entries not placed correctly:

              One weird thing to note is that it used to appear correctly before I added it to a particular layout.

              That's a nice clue!

              Could you post the layout code and where you add the combobox to it?

              M Offline
              M Offline
              MaxDevI
              wrote on last edited by
              #5

              @VRonin Thanks, I am just using a QGridLayout inside a QVBoxLayout as the main layout. Not sure where the child/parent handling problem came about.

              1 Reply Last reply
              0

              • Login

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