PDA

View Full Version : Frameless QChart in QChartview not possible?



mustermann.klaus@gmx.de
5th May 2019, 17:29
Hello everybody,

Sorry for that longer piece of code, but I read ALL the internet. Nothing helpful so far.



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);
}


... gives me two frameless colorbars and a chart wich is not frameless at all.

13115



The splitter-handles are configurable. Any ideas?

Cheers, Lars