I'm trying to make a time picker of sorts, but I'm having massive problems trying to align everything.

Basically, I have a

QVBoxLayout that has 3 QHBoxLayout that contain, each, a Label and a ComboBox (except a very particular case of "date range" selection.

I want to align all the widgets and that's just not happening, no matter what I try.

I'm not using neither designer or creator. I'm on VS2008 and drawing every widget by hand.

Any help on this issue, as well as required "extra" info such as code snipets, please feel free to request.

Qt Code:
  1. TimeRangeSelector::TimeRangeSelector(QWidget *parent)
  2. {
  3. //Main level
  4. Qt::AlignRight;
  5. m_pMainLayout = new QVBoxLayout();
  6. itemCont->setLayout(m_pMainLayout);
  7. itemCont->setMinimumSize(600, 400);
  8.  
  9. //First Level
  10. QHBoxLayout * pHBox1 = new QHBoxLayout();
  11. m_pMainLayout->setContentsMargins(0,0,5,5);
  12. m_pMainLayout->addLayout(pHBox1);
  13. QVRLabel * phBox1_pLabel1 = new QVRLabel("Period: ");
  14. phBox1_pLabel1->setAlignment(Qt::AlignHCenter);
  15. m_phBox1_pComboBox1 = new QVRComboBox();
  16.  
  17. m_phBox1_pComboBox1->setMinimumHeight(30);
  18. m_phBox1_pComboBox1->setMaximumWidth(100);
  19. m_phBox1_pComboBox1->addItem(" Hour");
  20. m_phBox1_pComboBox1->addItem(" Day");
  21. m_phBox1_pComboBox1->addItem(" Week");
  22. m_phBox1_pComboBox1->addItem(" Month");
  23. m_phBox1_pComboBox1->addItem(" Year");
  24. m_phBox1_pComboBox1->addItem(" Date Range");
  25. m_phBox1_pComboBox1->addItem(" Historical");
  26. pHBox1->addWidget(phBox1_pLabel1);
  27. pHBox1->addWidget(m_phBox1_pComboBox1);
  28.  
  29. //Second Level
  30. QHBoxLayout * pHBox2 = new QHBoxLayout();
  31. m_pMainLayout->addLayout(pHBox2);
  32. m_widget1 = new QStackedWidget();
  33. m_widget2 = new QStackedWidget();
  34. QStackedWidget * m_dateRangeFromAux = new QStackedWidget();
  35. m_widget1->setMaximumHeight(30);
  36. m_widget2->setMaximumHeight(30);
  37. m_dateRangeFromAux->setMaximumHeight(50);
  38. generateSecondLevelWidgets(pHBox2, m_widget1, m_widget2, "Hours");
  39. generateSecondLevelWidgets(pHBox2, m_widget1, m_widget2, "Days");
  40. generateSecondLevelWidgets(pHBox2, m_widget1, m_widget2, "Weeks");
  41. generateSecondLevelWidgets(pHBox2, m_widget1, m_widget2, "Months");
  42. generateSecondLevelWidgets(pHBox2, m_widget1, m_widget2, "Years");
  43. QVRLabel * label = new QVRLabel(" From:");
  44. QLineEdit * date = new QLineEdit("MM / DD / YYYY");
  45. QVRTimePicker * timepicker = new QVRTimePicker();
  46. m_widget1->addWidget(label);
  47. m_widget2->addWidget(date);
  48. m_dateRangeFromAux->addWidget(timepicker);
  49. pHBox2->addWidget(m_widget1);
  50. pHBox2->addWidget(m_widget2);
  51. pHBox2->addWidget(m_dateRangeFromAux);
  52.  
  53. // Third Level
  54. QHBoxLayout * pHBox3 = new QHBoxLayout();
  55. m_pMainLayout->addLayout(pHBox3);
  56. m_widget3 = new QStackedWidget();
  57. m_widget4 = new QStackedWidget();
  58. m_widget3->setMaximumHeight(30);
  59. m_widget4->setMaximumHeight(30);
  60. generateThirdLevelWidgets(pHBox3, m_widget3, m_widget4, "Hours");
  61. generateThirdLevelWidgets(pHBox3, m_widget3, m_widget4, "Days");
  62. generateThirdLevelWidgets(pHBox3, m_widget3, m_widget4, "Weeks");
  63. generateThirdLevelWidgets(pHBox3, m_widget3, m_widget4, "Months");
  64. generateThirdLevelWidgets(pHBox3, m_widget3, m_widget4, "Years");
  65. m_widget3->hide();
  66. m_widget4->hide();
To copy to clipboard, switch view to plain text mode 

I'm also attaching an IMG of "What I got" vs "What I expected":