下記のコードの
for (int i = 0; i <= 7; i++) { this->scene()->addRect(offset, 0 + (240 * i), measure_x_draw, 20, pen, brush); }
の部分でこのようなエラーが出ました。どうすればいいのでしょうか
C2664 'QGraphicsRectItem *QGraphicsScene::addRect(qreal,qreal,qreal,qreal,const QPen &,const QBrush &)': 引数 5 を 'QPen *' から 'const QPen &' へ変換できません。 (ソース ファイルをコンパイルしています SiVo.cpp) QtGuiApplication1 C:\Users\yuu\source\repos\QtGuiApplication1\QtGuiApplication1\Editor.cpp 67
C++
1#include <QtWidgets> 2#include <QtCore> 3#include <stdio.h> 4 5class QGraphicsTextItemFixed : public QGraphicsTextItem 6{ 7public: 8 QRectF boundingRect(); 9 void forceSize(int x, int y, int width); 10private: 11 QRectF forcedSize; 12 13}; 14QRectF QGraphicsTextItemFixed::boundingRect() 15{ 16 this->forcedSize = QRectF(0, 0, 10, 20); 17 return forcedSize; 18} 19void QGraphicsTextItemFixed::forceSize(int x, int y, int width) 20{ 21 forcedSize.setCoords(0, 0, width, 20); 22 setPos(x, y); 23} 24class NoteEditor : public QGraphicsView 25{ 26 QString select_tool = "Select"; 27 int new_measure_count = 0; 28 int measure_count = 0; 29 int start_mouse_press_x = 0; 30 int start_mouse_press_y = 0; 31 int end_mouse_press_x = 0; 32 int end_mouse_press_y = 0; 33 int mouse_start_button = 0; 34 void initUI(); 35 void drawMeasure(int measure_off_no, int measure_count); 36}; 37 38void NoteEditor::initUI() 39{ 40 QGraphicsScene *scene = new QGraphicsScene(this); 41 this->setScene(scene); 42 QGraphicsRectItem *current_draw = new QGraphicsRectItem(); 43 int quantize = 4; 44 int grid = 4; 45 this->select_tool = "Select"; 46 this->drawMeasure(0, 50); 47} 48void NoteEditor::drawMeasure(int measure_off_no, int measure_count = 1) 49{ 50 new_measure_count += measure_count; 51 QBrush* brush = new QBrush(QColor(90, 90, 90)); 52 QPen* pen = new QPen(QColor(45, 45, 45)); 53 pen->setWidth(2); 54 55 QBrush* brush2 = (QColor(60, 60, 60)); 56 QPen* pen2 = new QPen(QColor(75, 75, 75)); 57 pen2->setWidth(2); 58 59 QBrush *brush3 = new QBrush(QColor(120, 120, 120)); 60 QPen *pen3 = new QPen(QColor(105, 105, 105)); 61 pen3->setWidth(2); 62 63 int measure_x_draw = measure_count * 480; 64 int offset = measure_off_no * 480; 65 66 for (int i = 0; i <= 7; i++) { 67 this->scene()->addRect(offset, 0 + (240 * i), measure_x_draw, 20, pen, brush); 68 } 69} 70
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/16 04:25
2019/05/16 04:39
2019/05/16 04:58