qpainter

drawing icons in a table with QStyledItemDelegate paint()

拈花ヽ惹草 提交于 2019-12-24 10:58:04
问题 I'm trying to implement a custom paint function for a QStyledItemDelegate subclass (QT4.8.2). I've reviewed the StarItemDelegate example, among others, and it appears to be pretty straightforward. The delegate is assigned to a column of the table that indicates the record state. Column items are editable, but not user editable. I've implemented the delegate subclass and have proven that it works, but can't seem to get it to draw a simple icon. The code for the paint function is: { painter-

QPainterPath drawing and placering items along multiple paths

限于喜欢 提交于 2019-12-24 08:01:42
问题 I have from previous codelines developed and added some special behaviour. The idea is to draw small circle shapes on a certain path inside rectangular shape and circular shape and place them according to the distance given in advance. I want to draw automatically and programmatically based on given distance by user. ie. distance and number will vary. I have looked myself at this exercise, and reached to solve this with very complicated for-loops and long codelines. I am afraid of repeating

How to draw with QPainter on a specific widget from a group of widgets in QMainWindow?

只谈情不闲聊 提交于 2019-12-24 07:54:45
问题 This is my code: #include "mainwindow.h" #include <QDebug> #include <QCameraInfo> #include <QHBoxLayout> #include <fstream> #include <assert.h> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { m_QPushButton_calibration = new QPushButton("Calibrate", this); connect(m_QPushButton_calibration, SIGNAL (released()),this, SLOT (handleButton())); QList<QCameraInfo> l_QListQCameraInfo_available_cameras = QCameraInfo::availableCameras(); m_QWidget_viewfinder_holder = new QWidget; m

Get visible area of QPainter

半城伤御伤魂 提交于 2019-12-24 01:42:51
问题 I have an owner-drawn QWidget inside a QScrollArea , so when painting, and I want to paint only the parts that are visible. To do so, I need to have the rectangle of the visible area of the QPainter . The only candidates were QPainter::viewport() , QPainter::window() , and QPainter::clipBoundingRect() , so I put this code to log their output: setMinimumHeight(3000); setMinimumWidth(3000); } void MyWidget::paintEvent(QPaintEvent *) { QPainter painter(this); qDebug() << painter.viewport() <<

QPainter::drawPixmap() doesn't look good and has low quality?

妖精的绣舞 提交于 2019-12-21 02:30:28
问题 I'm trying to draw an icon(.png) inside a QWidget with QPainter::drawPixmap() : QPixmap _source = "/.../.png"; painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.drawPixmap(rect(), _source); but in comparing to QLabel (for example) and in lower size (19*19 in my case) the result isn't perfect. What can I do? ****Edit**** QLabel with pixmap @ size 19*19: My painting @ size 19*19 via SmoothPixmapTransform render type: 回答1: You are setting the wrong render hint, you need QPainter:

how to send Qline coordinate to a QPainter Widget

浪尽此生 提交于 2019-12-20 05:36:07
问题 I created a Qwidget, Form_temp, that draw lines based on an array of data created in the parent widget MainWindow. The issue I face is the data I send from the MainWindow to Form_temp via the slot send_data is not seen by other functions in Form_temp. (paintEvent). I am not able to figure out the loop hole. I added few Debug points to validate that the data arrives in Form_temp. Here is the code with some explanation. I did this with QTCreator Please help, I spend few days on this and am not

How to use QPainter on QPixmap

寵の児 提交于 2019-12-18 14:52:18
问题 I'm a newbie to Qt/Embedded. I want to use QPainter to draw stuff on a QPixmap , which will be added to QGraphicsScene . Here is my code. But it does not show the drawings on the pixmap. It shows only the black pixmap. int main(int argc, char **argv) { QApplication a(argc, argv); QMainWindow *win1 = new QMainWindow(); win1->resize(500,500); win1->show(); QGraphicsScene *scene = new QGraphicsScene(win1); QGraphicsView view(scene, win1); view.show(); view.resize(500,500); QPixmap *pix = new

How to use QPainter on QPixmap

余生颓废 提交于 2019-12-18 14:52:02
问题 I'm a newbie to Qt/Embedded. I want to use QPainter to draw stuff on a QPixmap , which will be added to QGraphicsScene . Here is my code. But it does not show the drawings on the pixmap. It shows only the black pixmap. int main(int argc, char **argv) { QApplication a(argc, argv); QMainWindow *win1 = new QMainWindow(); win1->resize(500,500); win1->show(); QGraphicsScene *scene = new QGraphicsScene(win1); QGraphicsView view(scene, win1); view.show(); view.resize(500,500); QPixmap *pix = new

Draw rich text with QPainter

南笙酒味 提交于 2019-12-17 18:38:21
问题 is there a way to draw fixed text that has subscripts. My goal is to have something like: "K_max=K_2 . 3" QString equation="K_max=K_2 . 3"; painter.drawText( QRect(x, y , width, y+height), Qt::AlignLeft|Qt::AlignVCenter, equation); I also tried formatting the text using html tags but it didn't help (tags got printed with the text): QString equation="<p>K<sub>max</sub></p>=<p>K<sub>2</sub></p>.3" 回答1: Here is a full example using rich text of QTextDocument. mainWindow.cpp: #include "mainWindow

Get list of points affected by drawLine() or QLineF

五迷三道 提交于 2019-12-12 17:49:42
问题 How do I get a list of points/coordinates that the drawLine() function affects? For example if I have QLineF line(10.0, 80.0, 90.0, 20.0); QPainter(this); painter.drawLine(line); I want to get the list of QPoint coordinates that the drawLine() will draw. I'm aware of Bresenham's line algorithm, however I need this to work in a more general case where I can set different QPen and QBrush: painter.setPen(QPen(myColor, myWidth, Qt::SolidLine, Qt::RoundCap)); I also need it to be consistent with