C++ (Qt)#include "clistwidgetlegendgraph2d.h"#include <QtGui/QApplication> int main(int argc, char *argv[]){ QApplication a(argc, argv); QGraphicsScene scene(QRect(0,0,640,480)); CListLegend list(0); list.addItems(QStringList()<<"sfdsdfshhhhhhhhhhhhhhhhdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"<<"sfdsdfsdf"<<"sdf"); scene.addWidget(&list); scene.addWidget(new QPushButton("button",0)); QPixmap pixmap(scene.sceneRect().width(),scene.sceneRect().height()); QPainter painter(&pixmap); painter.setRenderHint(QPainter::Antialiasing); scene.render(&painter); painter.end(); pixmap.save("scene.png","png"); QGraphicsView view(&scene); view.show(); return a.exec();}
C++ (Qt)QPixmap toPixmap(const QSize &s);
C++ (Qt)void CPlotter2d::paintEvent(QPaintEvent * /* event */){ QStylePainter painter(this); painter.drawPixmap(0, 0,pixmap);// mg);*/ //refreshPixmap(opt_graph); } void CPlotter2d::resizeEvent(QResizeEvent * /* event */){ if(opt_graph.width_widget != this->size().width() || opt_graph.height_widget != this->size().height() ) { opt_graph.width_widget = this->size().width(); opt_graph.height_widget = this->size().height(); pixmap= refreshPixmap(opt_graph); } // refreshPixmap(opt_graph);}