質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Qt

QtはGUIプログラムの開発で広く使われているクロスプラットフォーム開発のフレームワークです。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

0回答

398閲覧

メインのウィンドウにQGraphicsViewを配置する方法

kemomimi_sabal

総合スコア12

Qt

QtはGUIプログラムの開発で広く使われているクロスプラットフォーム開発のフレームワークです。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2019/05/16 11:37

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上に図形を描画したいのですが、調べても出てきませんでした。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問