en (QIODevice :: ReadOnly))
{(! streamEnd ())
{list=stream.readLine (). split ( laquo ;; , QString :: SkipEmptyParts);
//qDebug () lt; lt; list; _piano- gt; at (list (0) .toInt ()) - gt; start=QTime::fromString(list(1),laquo;hh:mm:ss.zzzraquo;);_piano-gt;at(list(0).toInt())-gt;que-gt;clear();(int i=2; i lt; list.count (); ++ i)
{_piano-gt;at(list(0).toInt())-gt;que-gt;enqueue(QTime::fromString(list(i),laquo;hh:mm:ss.zzzraquo;));
}
}
}. close ();
}
} MainWindow :: saveFile ()
{str=QFileDialog :: getSaveFileName (this, Зберегти запис , QString (), My melody files (* .mym) ); (! str.isEmpty ())
{file (str); stream ( amp; file); (file.open (QIODevice :: WriteOnly))
{(int i=0; i lt; list_piano- gt; count (); ++ i)
{ lt; QTime gt; temp=* list_piano- gt; at (i) - gt; que; (temp.count () gt; 0)
{ lt; lt; QString :: number (i) + laquo ;; raquo ;; lt; lt; list_piano-gt;at(i)-gt;start.toString(laquo;hh:mm:ss.zzzraquo;)+laquo;;raquo;;(!temp.isEmpty())
{ lt; lt; temp.dequeue (). toString ( hh: mm: ss.zzz ) + laquo ;; raquo ;;
} lt; lt; n raquo ;;
}
}
}. close ();
}
}MainWindow::about_dev(){::information(this,laquo;Разработчикraquo;,laquo;Резанов Богдан КИТ - 83 );
}
Pianobutton.cpp
# include pianobutton.h :: PianoButton (QWidget * parent, QString name): (parent), start (QTime :: currentTime ()), summ (0), isRecord (false )
{= new QSoundEffect; new QQueuelt;QTimegt;;gt;setFixedSize(50,100);gt;setText(name);gt;setCheckable(true);(this,SIGNAL(pressed()),this,SLOT(onMousePress()));(this,SIGNAL(released()),this,SLOT(onMouseRelease()));(effect,amp;QSoundEffect::playingChanged,this,[=]()
{(! effect- gt; isPlaying ())
{ gt; setChecked (false);
}
}); PianoButton :: timerEvent (QTimerEvent * e)
{ gt; play (); gt; setChecked (true); gt; killTimer (e- gt; timerId ());
} PianoButton :: onPress (QKeyEvent * event)
{notes= Q1W2ER4T5Y6UI8O9P [-] =, K.ZAXSCVFBGNHM raquo ;; c (event- gt; key ()); (this- gt; text (). indexOf (c)!= - 1)
{(! this- gt; isChecked ())
{ gt; play ();
} gt; setChecked (true);
}
} PianoButton :: onPress (QKeyEvent * event, QTime elapsed)
{c (event- gt; key ()); (this- gt; text (). indexOf (c)!=- 1)
{(! this- gt; isChecked ())
{ gt; enqueue (elapsed); () lt; lt; start.msecsTo (elapsed);
}
} gt; onPress (event);
} PianoButton :: onRelease (QKeyEvent * event)
{notes= Q1W2ER4T5Y6UI8O9P [-] =, K.ZAXSCVFBGNHM raquo ;; c (event- gt; key ()); (this- gt; text (). indexOf (c)!= - 1)
{ gt; setChecked (false);
}
} PianoButton :: onRestart (QTime time)
{ gt; clear ();=time;=true;
} PianoButton :: onMousePress ()
{ gt; play (); gt; setChecked (true); (isRecord)
{ gt; enqueue (QTime :: currentTime ());
}
} PianoButton :: onMouseRelease ()
{ gt; setChecked (false);
} PianoButton :: onReplyRecord ()
{ lt; QTime gt; temp=* que; (! temp.isEmpty ())
{ gt; startTimer (start.msecsTo (temp.dequeue ()), Qt :: PreciseTimer);
}
} PianoButton :: onStopRecord ()
{= false;
}
3. Опис програми
. 1 Інтерфейс
Зовнішній вигляд готового і запущеного додатку (рис. 3.1).
Малюнок 3.1 - Зовнішній вигляд програми
Вікно програми містить компоненти QPushButton з позначеннями для гри на клавіатурі. Натискаючи на них, можна програти мелодію (рис. 3.2).
У меню запропоновано записати і...