Results 1 to 1 of 1

Thread: Frameless QChart in QChartview not possible?

  1. #1
    Join Date
    May 2015
    Posts
    35
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Frameless QChart in QChartview not possible?

    Hello everybody,

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

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow){
    4.  
    5. // hide unnecessary things
    6. ui->setupUi(this);
    7. ui->mainToolBar->hide();
    8. ui->statusBar->hide();
    9.  
    10.  
    11. // create central widget and layout
    12. QWidget *mainWidget = new QWidget(this);
    13. QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
    14. setCentralWidget(mainWidget);
    15.  
    16.  
    17. // create a splitter and two colorfull dummies
    18. QSplitter *splitter = new QSplitter(this);
    19.  
    20. QWidget *dummy1 = new QWidget(this);
    21. QWidget *dummy2 = new QWidget(this);
    22. dummy1->setStyleSheet("background-color: rgb(255, 100, 100)");
    23. dummy2->setStyleSheet("background-color: rgb(100, 100, 255)");
    24. dummy1->setMinimumSize(100,100);
    25. dummy2->setMinimumSize(100,100);
    26.  
    27. // create a chart in a chartview
    28. chart = new QChart();
    29. chart->setMinimumSize(800, 600);
    30. chart->setBackgroundBrush(QBrush(QColor(Qt::yellow)));
    31. chartView = new QChartView(chart);
    32.  
    33. // add all to splitter
    34. splitter->addWidget(dummy1);
    35. splitter->addWidget(chartView);
    36. splitter->addWidget(dummy2);
    37. splitter->setSizes(QList<int>() << 200 << 200 << 200);
    38.  
    39.  
    40. // remove contentMargins
    41. chart -> setContentsMargins(0,0,0,0);
    42. chartView -> setContentsMargins(0,0,0,0);
    43. splitter -> setContentsMargins(0,0,0,0);
    44. mainLayout -> setContentsMargins(0,0,0,0);
    45.  
    46. // output
    47. mainLayout->addWidget(splitter);
    48. }
    To copy to clipboard, switch view to plain text mode 

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

    framelessChart.jpg



    The splitter-handles are configurable. Any ideas?

    Cheers, Lars
    Last edited by mustermann.klaus@gmx.de; 5th May 2019 at 19:00.

Similar Threads

  1. QChartView and QScatterSeries overrdide the label of a QPointF
    By ironexmaiden in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2018, 22:00
  2. Save QChartView as PNG
    By Carlsberg in forum Qt Programming
    Replies: 1
    Last Post: 24th June 2017, 16:44
  3. QChart Questions
    By rhb327 in forum Qt Programming
    Replies: 0
    Last Post: 17th May 2017, 11:04
  4. adding new QChart in a QChartView
    By zemlemer in forum Newbie
    Replies: 0
    Last Post: 24th April 2017, 19:58
  5. Problem getting QChartView to display
    By derrickbj in forum Qt Programming
    Replies: 5
    Last Post: 20th September 2016, 16:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.