MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow){
// hide unnecessary things
ui->setupUi(this);
ui->mainToolBar->hide();
ui->statusBar->hide();
// create central widget and layout
setCentralWidget(mainWidget);
// create a splitter and two colorfull dummies
dummy1->setStyleSheet("background-color: rgb(255, 100, 100)");
dummy2->setStyleSheet("background-color: rgb(100, 100, 255)");
dummy1->setMinimumSize(100,100);
dummy2->setMinimumSize(100,100);
// create a chart in a chartview
chart = new QChart();
chart->setMinimumSize(800, 600);
chartView = new QChartView(chart);
// add all to splitter
splitter->addWidget(dummy1);
splitter->addWidget(chartView);
splitter->addWidget(dummy2);
splitter->setSizes(QList<int>() << 200 << 200 << 200);
// remove contentMargins
chart -> setContentsMargins(0,0,0,0);
chartView -> setContentsMargins(0,0,0,0);
splitter -> setContentsMargins(0,0,0,0);
mainLayout -> setContentsMargins(0,0,0,0);
// output
mainLayout->addWidget(splitter);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow){
// hide unnecessary things
ui->setupUi(this);
ui->mainToolBar->hide();
ui->statusBar->hide();
// create central widget and layout
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
setCentralWidget(mainWidget);
// create a splitter and two colorfull dummies
QSplitter *splitter = new QSplitter(this);
QWidget *dummy1 = new QWidget(this);
QWidget *dummy2 = new QWidget(this);
dummy1->setStyleSheet("background-color: rgb(255, 100, 100)");
dummy2->setStyleSheet("background-color: rgb(100, 100, 255)");
dummy1->setMinimumSize(100,100);
dummy2->setMinimumSize(100,100);
// create a chart in a chartview
chart = new QChart();
chart->setMinimumSize(800, 600);
chart->setBackgroundBrush(QBrush(QColor(Qt::yellow)));
chartView = new QChartView(chart);
// add all to splitter
splitter->addWidget(dummy1);
splitter->addWidget(chartView);
splitter->addWidget(dummy2);
splitter->setSizes(QList<int>() << 200 << 200 << 200);
// remove contentMargins
chart -> setContentsMargins(0,0,0,0);
chartView -> setContentsMargins(0,0,0,0);
splitter -> setContentsMargins(0,0,0,0);
mainLayout -> setContentsMargins(0,0,0,0);
// output
mainLayout->addWidget(splitter);
}
To copy to clipboard, switch view to plain text mode
Bookmarks