Hi community,
I am having some issue placing 5 items in a grid layout.
Each item is an horizontal layout composed by a QComboBox and a QLabel.

I would like to place the items in this way:

| H_1 | <==> | H_2 |

| H_3 | <==> | H_4 |

| H_5 | <=======|

The arrows between H1,H2 and H3,H4 indicate that the items should be pushed to the extremes when the grid is resized while H5 should be pushed to the left side.

I also set the SizeAdjustPolicy of the 5 combo boxes to the AdjustToContents flag to adjust its size fit to fit the content, but seems not having effect in my code.
The grid layout will be then added to a vertical layout.

Below the code snippet I wrote:

Qt Code:
  1. QVBoxLayout *radarBiasVerticalLayout = new QVBoxLayout(stackPageRadarBias_);
  2.  
  3. // The 5 horizontal layouts
  4. QHBoxLayout *timeBiasHBox = new QHBoxLayout;
  5. QHBoxLayout *rangeBiasHBox = new QHBoxLayout;
  6. QHBoxLayout *rangeGainBiasHBox = new QHBoxLayout;
  7. QHBoxLayout *azimuthBiasHBox = new QHBoxLayout;
  8. QHBoxLayout *eccentricityBiasHBox = new QHBoxLayout;
  9.  
  10. // The 5 combo boxes
  11. cb_time_bias = new QComboBox; // CB1
  12. cb_time_bias->setSizeAdjustPolicy(QComboBox::AdjustToContents);
  13. cb_range_bias = new QComboBox; // CB2
  14. cb_range_bias->setSizeAdjustPolicy(QComboBox::AdjustToContents);
  15. cb_rangeGain_bias = new QComboBox; // CB3
  16. cb_rangeGain_bias->setSizeAdjustPolicy(QComboBox::AdjustToContents);
  17. cb_azimuth_bias = new QComboBox; // CB4
  18. cb_azimuth_bias->setSizeAdjustPolicy(QComboBox::AdjustToContents);
  19. cb_eccentricity_bias = new QComboBox; // CB5
  20. cb_eccentricity_bias->setSizeAdjustPolicy(QComboBox::AdjustToContents);
  21.  
  22. // The 5 labels
  23. lbl_time_bias = new QLabel("Set time for all radars"); // label1
  24. lbl_range_bias = new QLabel("Set range for all radars"); // label2
  25. lbl_rangeGain_bias = new QLabel("Set range gain for all radars"); // label3
  26. lbl_azimuth_bias = new QLabel("Set azimuth for all radars"); // label4
  27. lbl_eccentricity_bias = new QLabel("Set eccentricity for all radars"); // label5
  28.  
  29. timeBiasHBox->addWidget(cb_time_bias);
  30. timeBiasHBox->addWidget(lbl_time_bias);
  31.  
  32. rangeBiasHBox->addWidget(cb_range_bias);
  33. rangeBiasHBox->addWidget(lbl_range_bias);
  34.  
  35. rangeGainBiasHBox->addWidget(cb_rangeGain_bias);
  36. rangeGainBiasHBox->addWidget(lbl_rangeGain_bias);
  37.  
  38. azimuthBiasHBox->addWidget(cb_azimuth_bias);
  39. azimuthBiasHBox->addWidget(lbl_azimuth_bias);
  40.  
  41. eccentricityBiasHBox->addWidget(cb_eccentricity_bias);
  42. eccentricityBiasHBox->addWidget(lbl_eccentricity_bias);
  43.  
  44. // Layout the items into the grid
  45. grid->setHorizontalSpacing(50);
  46. grid->addLayout(timeBiasHBox, 0, 0);
  47. grid->addLayout(rangeBiasHBox, 0, 1);
  48. grid->addLayout(rangeGainBiasHBox, 1, 0);
  49. grid->addLayout(azimuthBiasHBox, 1, 1);
  50. grid->addLayout(eccentricityBiasHBox, 2, 0, 2, 1, Qt::AlignLeft);
  51.  
  52. // Add the grid to the vertical layout
  53. radarBiasVerticalLayout->addLayout(grid);
To copy to clipboard, switch view to plain text mode 

The final result of my code is the one in this picturebad.png while it should be like in this other picturegood.png
I can not set the comboboxes to the correct size to have the correct result.

I hope to get some help here.
Thanx in advance,
Franco