In qt, is there a way to write on the perimeter of a circle?
-
You can do it but using custom QPainter code in a widget (same in QML). There is no built-in widget for this, as far as I'm aware.
-
Hi, you can use widgets for a simple rotation, start with an empty vanilla Qt Widgets app, then change your mainwindow.cpp to look like this:
#include "mainwindow.h" #include "ui_mainwindow.h" #include "qgraphicsview.h" #include "qgraphicsscene.h" #include "qgraphicsproxywidget.h" #include "qlabel.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); auto graphicsView = new QGraphicsView(ui->centralwidget); graphicsView->setGeometry(0,0,width(),height()); auto scene = new QGraphicsScene(this); auto diameter = qMin(graphicsView->width(),graphicsView->height()) / 1.2; QString s = "Now is the time for all good men to come to the aid of the party."; for (int i = 0; (i < s.length()); ++i) { auto c = s[i]; if (' ' == c) // skip blanks continue; QGraphicsProxyWidget* w = scene->addWidget(new QLabel(c)); auto turn90 = i - s.size() / 4; auto rotRadians = (turn90 * 2 * 3.141592653) / s.length(); w->setPos(diameter * cos(rotRadians) / 2,diameter * sin(rotRadians) / 2); auto rotDegrees = (i * 360) / s.length(); w->setRotation(rotDegrees); } graphicsView->setScene(scene); } MainWindow::~MainWindow() { delete ui; }running it:

Edit: forgot to include the code to add the QGraphicsView to the mainwidget, now ok :-)
-
Hi, you can use widgets for a simple rotation, start with an empty vanilla Qt Widgets app, then change your mainwindow.cpp to look like this:
#include "mainwindow.h" #include "ui_mainwindow.h" #include "qgraphicsview.h" #include "qgraphicsscene.h" #include "qgraphicsproxywidget.h" #include "qlabel.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); auto graphicsView = new QGraphicsView(ui->centralwidget); graphicsView->setGeometry(0,0,width(),height()); auto scene = new QGraphicsScene(this); auto diameter = qMin(graphicsView->width(),graphicsView->height()) / 1.2; QString s = "Now is the time for all good men to come to the aid of the party."; for (int i = 0; (i < s.length()); ++i) { auto c = s[i]; if (' ' == c) // skip blanks continue; QGraphicsProxyWidget* w = scene->addWidget(new QLabel(c)); auto turn90 = i - s.size() / 4; auto rotRadians = (turn90 * 2 * 3.141592653) / s.length(); w->setPos(diameter * cos(rotRadians) / 2,diameter * sin(rotRadians) / 2); auto rotDegrees = (i * 360) / s.length(); w->setRotation(rotDegrees); } graphicsView->setScene(scene); } MainWindow::~MainWindow() { delete ui; }running it:

Edit: forgot to include the code to add the QGraphicsView to the mainwidget, now ok :-)
@hskoglund thanks so much
