Solved QComboBox Entries not placed correctly
-
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^^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.
-
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.
-
@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?
-
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.
-
@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
-
@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.