C++
1sample::sample(QWidget *parent) 2 : QMainWindow(parent) 3{ 4 ui.setupUi(this); 5 makeStatusBar(); 6 makeMenuandAction(); 7 open(); 8 select(); 9 pen(); 10 rsz(); 11 flag_view_Toggle(); 12 erase(); 13 this->showFlg = true; 14 QTimer *timer = new QTimer(this); 15 connect(timer, SIGNAL(timeout()), this, SLOT(rsz)); 16 timer->start(); 17} 18 19void sample::makeStatusBar() 20{ 21 statusBar()->showMessage(tr("this is status bar")); 22} 23 24void sample::makeMenuandAction() 25{ 26noteEditor* track = new noteEditor(); 27 track->show(); 28} 29 30QGraphicsTextItemFixed::QGraphicsTextItemFixed(QGraphicsTextItem *parent) 31 : QGraphicsTextItem(parent) 32{ 33 QString text; 34} 35 36QRectF QGraphicsTextItemFixed::boundingRect() const { 37 QRectF forcedSize = QRectF(0, 0, 10, 20); 38 return forcedSize; 39} 40 41void QGraphicsTextItemFixed::forceSize(int x, int y, int width) 42{ 43 forcedSize->setCoords(0, 0, width, 20); 44 this->setPos(x, y); 45} 46 47noteEditor::noteEditor(QGraphicsView *parent) 48 :QGraphicsView(parent) 49{ 50} 51 52void noteEditor::initUI() 53{ 54 QGraphicsScene *scene = new QGraphicsScene(); 55 this->setScene(scene); 56 57 QGraphicsRectItem *currentDraw = new QGraphicsRectItem(); 58 this->mouseDown = false; 59 this->isDrag = false; 60 this->quantize = 4; 61 this->grid = 4; 62 this->select_tool = "Select"; 63 drawMeasure(0, 50); 64} 65void noteEditor::drawMeasure(int measureOffNo = 1, int measureCnt = 1) 66{ 67 newmeasureCnt += measureCnt; 68 QBrush brush = (QColor(90, 90, 90)); 69 QPen pen = (QColor(45, 45, 45)); 70 pen.setWidth(2); 71 72 QBrush brush2 = (QColor(60, 60, 60)); 73 QPen pen2 = (QColor(75, 75, 75)); 74 pen2.setWidth(2); 75 76 QBrush brush3 = (QColor(120, 120, 120)); 77 QPen pen3 = (QColor(105, 105, 105)); 78 79 int measureXDraw = measureCnt * 480; 80 int offset = measureOffNo * 480; 81 82 for (int i = 0; i <= 7; i++) { 83 84 this->scene()->addRect(offset, 0.0 + (240 * i), measureXDraw, 20, pen, brush); 85 this->scene()->addRect(offset, 20.0 + (240 * i), measureXDraw, 20, pen2, brush2); 86 this->scene()->addRect(offset, 40.0 + (240 * i), measureXDraw, 20, pen, brush); 87 this->scene()->addRect(offset, 60.0 + (240 * i), measureXDraw, 20, pen2, brush2); 88 this->scene()->addRect(offset, 80.0 + (240 * i), measureXDraw, 20, pen, brush); 89 this->scene()->addRect(offset, 100.0 + (240 * i), measureXDraw, 20, pen2, brush2); 90 this->scene()->addRect(offset, 120.0 + (240 * i), measureXDraw, 20, pen, brush); 91 this->scene()->addRect(offset, 140.0 + (240 * i), measureXDraw, 20, pen, brush); 92 this->scene()->addRect(offset, 160.0 + (240 * i), measureXDraw, 20, pen2, brush2); 93 this->scene()->addRect(offset, 180.0 + (240 * i), measureXDraw, 20, pen, brush); 94 this->scene()->addRect(offset, 200.0 + (240 * i), measureXDraw, 20, pen2, brush2); 95 this->scene()->addRect(offset, 220.0 + (240 * i), measureXDraw, 20, pen3, brush3); 96 } 97}
上記のコードでQMainWindow上に図形を描画したいのですが、調べても出てきませんでした。
あなたの回答
tips
プレビュー