Good day All.
Ive been using qt creator to do all my qt application development and therefore using ui pages in creator for design layout.
How ever i have the need to create a widget or dialog that i would like to do solely in code no ui page.

This is what i have done so far.

I created a new C++ class not qt class so it doesnt include the ui file.
the file is named "frm_maintenance_all"
I then included the file and open it so in my mainwindow.cpp

Qt Code:
  1. void MainWindow::openMaintenance()
  2. {
  3. frm_maintenance_all *newform = new frm_maintenance_all;
  4.  
  5. }
To copy to clipboard, switch view to plain text mode 

Then my header is

Qt Code:
  1. #ifndef FRM_MAINTENANCE_ALL_H
  2. #define FRM_MAINTENANCE_ALL_H
  3.  
  4. #include <QWidget>
  5. #include <QDialog>
  6. #include <QtGui>
  7. #include <QApplication>
  8.  
  9. class frm_maintenance_all : public QWidget
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit frm_maintenance_all(QWidget *parent = 0);
  14.  
  15. signals:
  16.  
  17. public slots:
  18.  
  19. private slots:
  20. void frm_create(QString tablename);
  21.  
  22. };
  23.  
  24. #endif // FRM_MAINTENANCE_ALL_H
To copy to clipboard, switch view to plain text mode 

and my cpp is

Qt Code:
  1. #include "frm_maintenance_all.h"
  2.  
  3. frm_maintenance_all::frm_maintenance_all(QWidget *parent) :
  4. QWidget(parent)
  5. {
  6. frm_create("test");
  7.  
  8. }
  9.  
  10. void frm_maintenance_all::frm_create(QString tablename)
  11. {
  12.  
  13.  
  14. QWidget *frmnew = new QWidget;
  15. QVBoxLayout *myhoz = new QVBoxLayout;
  16.  
  17. QLineEdit *myline = new QLineEdit;
  18. QLineEdit *myline1 = new QLineEdit;
  19.  
  20. myhoz->addWidget(myline);
  21. myhoz->addWidget(myline1);
  22.  
  23. //attempt here to add myhoz to frmnew via frmnew->addLayout does not work
  24.  
  25. frmnew->show();
  26. frmnew->setWindowTitle("Maintenance Test");
  27.  
  28. }
To copy to clipboard, switch view to plain text mode 

you will see in the coment above i try to add the layout created to the frm however it does not give me the option to add widget or addlayout.
Is there something im doing wrong.

Or is there a better way to do this.

Regards