Ion
18th September 2014, 15:04
Hi there, currently not looking to make a custom widget for this as it is only a layout class object. What I want to do is be able to create a pane/window or whatever i need so that I can place a QWidget class (that i created in code instead of on the form) inside so that I can adjust the positions etc on Qt Designer.
So need two bits of information, one what item in Qt designer should i use to allow me to place a QWidget inside it?
and two, how do i then insert my class object into this window/pane ?
Layout class constructor listed below:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPalette p(palette());
p.setColor(QPalette::Background, Qt::lightGray);
this->setAutoFillBackground(true);
this->setPalette(p);
this->resize(1000,500);
this->setWindowTitle(QApplication::translate("toplevel", "CCTV"));
mplayer_wrapper *wrapper = new mplayer_wrapper(this);
label = new QLabel(this);
Timer = new QTimer(this);
button1 = new QPushButton("Stop State");
button2 = new QPushButton("Start Stream");
button3 = new QPushButton("Time");
vlayout = new QVBoxLayout();
vlayout->addWidget(wrapper);
vlayout->addWidget(button1);
vlayout->addWidget(button2);
vlayout->addWidget(button3);
vlayout->addWidget(label);
ui->centralWidget->setLayout(vlayout);
connect(button1, &QPushButton::clicked,wrapper,&mplayer_wrapper::stop_mplayer);
connect(button2, &QPushButton::clicked,wrapper,&mplayer_wrapper::start_mplayer);
//connect(button3, &QPushButton::clicked,this, &MainWindow::show_time);
connect(Timer,&QTimer::timeout,this,&MainWindow::show_time);
//ui->widget->
Timer->start();
}
Specifically in regards to this code I want to insert mplayer_wrappers object wrapper. 90% of this code I want to do on the designer as it's becoming a nightmare when the layout is alot more complicated.
So need two bits of information, one what item in Qt designer should i use to allow me to place a QWidget inside it?
and two, how do i then insert my class object into this window/pane ?
Layout class constructor listed below:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPalette p(palette());
p.setColor(QPalette::Background, Qt::lightGray);
this->setAutoFillBackground(true);
this->setPalette(p);
this->resize(1000,500);
this->setWindowTitle(QApplication::translate("toplevel", "CCTV"));
mplayer_wrapper *wrapper = new mplayer_wrapper(this);
label = new QLabel(this);
Timer = new QTimer(this);
button1 = new QPushButton("Stop State");
button2 = new QPushButton("Start Stream");
button3 = new QPushButton("Time");
vlayout = new QVBoxLayout();
vlayout->addWidget(wrapper);
vlayout->addWidget(button1);
vlayout->addWidget(button2);
vlayout->addWidget(button3);
vlayout->addWidget(label);
ui->centralWidget->setLayout(vlayout);
connect(button1, &QPushButton::clicked,wrapper,&mplayer_wrapper::stop_mplayer);
connect(button2, &QPushButton::clicked,wrapper,&mplayer_wrapper::start_mplayer);
//connect(button3, &QPushButton::clicked,this, &MainWindow::show_time);
connect(Timer,&QTimer::timeout,this,&MainWindow::show_time);
//ui->widget->
Timer->start();
}
Specifically in regards to this code I want to insert mplayer_wrappers object wrapper. 90% of this code I want to do on the designer as it's becoming a nightmare when the layout is alot more complicated.