#include#include int main(int argc, char *argv[]) { QApplication a(argc, argv); QLabel label("Draw Point Example"); QPainter painter(&label); painter.drawPoint(50, 50); label.show(); return a.exec(); }
#includeThis code creates a QLabel widget with the title "Draw Pattern Example". Then, it creates a QPainter object and passes in the QLabel widget as its device. It uses a for loop to calculate the x and y positions of each of the points in the pattern, which are then passed to drawPoint() to draw the points on the widget. The package library for QPainter is the Qt library.#include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QLabel label("Draw Pattern Example"); QPainter painter(&label); for(int i = 0; i < 360; i += 10) { int x = 50 + 50 * std::cos(i * M_PI / 180); int y = 50 + 50 * std::sin(i * M_PI / 180); painter.drawPoint(x, y); } label.show(); return a.exec(); }