gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
QT Draw Line code
- User
QT Draw Line code
- Assistant
Here is a sample code to draw a line using QT:
c++#include <QApplication> #include <QWidget> #include <QPainter> class MyWidget : public QWidget { public: MyWidget(QWidget *parent = nullptr) : QWidget(parent) {} protected: void paintEvent(QPaintEvent *event) override { QPainter painter(this); painter.setPen(QPen(Qt::black, 2)); painter.drawLine(50, 50, 200, 200); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); MyWidget widget; widget.resize(250, 250); widget.show(); return app.exec(); }This code creates a custom widget (
MyWidget) that overrides thepaintEventmethod to draw a line using theQPainterclass. ThesetPenmethod is used to set the line color and thickness, and thedrawLinemethod is called to draw the line from point(50,50)to point .
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.