]> code.delx.au - virtualtones/blobdiff - pianoinstrument.cpp
Updated to modern Qt
[virtualtones] / pianoinstrument.cpp
index 127d9e14ded50daf9eca339d68316ee9c96809c1..0fea76f387f52cf4cf1419b62acf876182bdf0ba 100644 (file)
@@ -5,21 +5,16 @@
 
 #include "pianoinstrument.h"
 
-
+using namespace Qt;
 
 
 PianoInstrument::PianoInstrument(QWidget *parent)
 : Instrument(parent)
 {
-       // Set us up to look pretty
-       setPaletteBackgroundPixmap(QPixmap("piano.png"));
-       setFixedSize(184, 220);
-       parentWidget()->setFixedSize(184, 220);
+       background.load("piano.png");
 
-       for(int i = 0; i < 26; i++) {
-               oldNotes[i] = false;
-               notes[i] = false;
-       }
+       memset(oldNotes, 0, sizeof(oldNotes));
+       memset(notes, 0, sizeof(notes));
 
        noteStart = 48;
 
@@ -57,6 +52,9 @@ QString PianoInstrument::generateHelp()
 void PianoInstrument::paintEvent(QPaintEvent *)
 {
        QPainter paint(this);
+
+       paint.drawPixmap(0, 0, background);
+
        paint.setPen(Qt::red);
 
        const int topBlackY = 38;
@@ -385,4 +383,3 @@ void PianoInstrument::emitSounds()
 
        repaint();
 }
-