C++ (Qt)class Track: public QWidget{QList<Takt> list_takt;}class Takt: public QWidget//наследник Track{QList<Position> list_position;}class Position:public QWidget //наследник Track
C++ (Qt)#ifndef Position_H#define Position_H #include "headers.h" class Position: public QWidget{ Q_OBJECTpublic: // Конструктор explicit Position( QWidget *this_track_transfered, int position_transfered, bool pause_transfered = false, unsigned short int dimensions_transfered = 6, unsigned short int strn_1_transfered = 80, unsigned short int strn_2_transfered = 80, unsigned short int strn_3_transfered = 80, unsigned short int strn_4_transfered = 80, unsigned short int strn_5_transfered = 80, unsigned short int strn_6_transfered = 80 ); //Обязательные функции реализации визуализации void paintEvent(); QSize sizeHint() const; QString note_to_str(unsigned short int note); void keyPressEvent(QKeyEvent *event); //get функции int get_pos(); private slots: void update(); void set_strn_1(QString note); void set_strn_2(QString note); void set_strn_3(QString note); void set_strn_4(QString note); void set_strn_5(QString note); void set_strn_6(QString note); void set_dim_up(); void set_dim_down(); void set_pause(); void check_pause(); //Переменныеprivate: bool pause; //если true, ставим паузу unsigned short int strn_1; // нотка на данной струне (0-24 ноты) (80 - пустота) unsigned short int strn_2; unsigned short int strn_3; unsigned short int strn_4; unsigned short int strn_5; unsigned short int strn_6; unsigned short int dimensions; // размерность нот на данной позиции {0 - 5} <=> целая - 32-ая, 6 - никакая int position; // последняя Иксовая позиция*/ QWidget *buff_widget; QPainter *painter; QLineEdit *s1; QLineEdit *s2; QLineEdit *s3; QLineEdit *s4; QLineEdit *s5; QLineEdit *s6;}; #endif // Position_H
C++ (Qt)void Position::keyPressEvent(QKeyEvent *event){ switch(event->key()) { case Qt::Key_Plus: { set_dim_up(); qDebug()<<"Plus_pressed"<<endl; break; } case Qt::Key_Minus: { set_dim_down(); qDebug()<<"Minus_pressed"<<endl; break; } }}
void QWidget::keyPressEvent ( QKeyEvent * event ) [virtual protected]