Skip to content

Just codefiles that can be read on both Linux-in-a-box, and Win10 on Desktop.. πŸ™„

Notifications You must be signed in to change notification settings

musikBear/musikBearLMMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

musikBearLMMS

Qt button Here is an example:

#ifndef DUALACTIONPUSHBUTTON_H #define DUALACTIONPUSHBUTTON_H

#include

class DualActionPushButton: public QPushButton { Q_OBJECT public: explicit DualActionPushButton(QWidget *p = nullptr); ~DualActionPushButton(); protected: void mousePressEvent(QMouseEvent *event);

};

#endif // DUALACTIONPUSHBUTTON_H

#include #include

DualActionPushButton::DualActionPushButton(QWidget *p): QPushButton(p) { }

DualActionPushButton::~DualActionPushButton() { }

void DualActionPushButton::mousePressEvent(QMouseEvent event) { if (event->button() == Qt::LeftButton) { qDebug() << "Left"; // trigger the first action in the button's action list (if there is one). QList<QAction> acts = this->actions(); if (acts.count() > 0) { acts.at(0)->trigger(); event->accept(); } }

else if (event->button() == Qt::RightButton) {
    qDebug() << "Right";
    // trigger the second action in the button's action list (if there is one)
    QList<QAction*> acts = this->actions();
    if (acts.count() > 1) {
        acts.at(1)->trigger();
        event->accept();
    }
}
// Ignore other options
event->ignore();

}

and the setup

QAction* strumNotesUpAction =
new QAction(tr( "Strum Selected by Q-value" ), this );
connect( strumNotesUpAction, &QAction::triggered,
         [=]() { qDebug() << "strumUp triggered"; } );

//2. button
QAction* strumNotesDnAction =
new QAction(tr( "Strum Selected by Q-value" ), this );
connect( strumNotesDnAction, &QAction::triggered,
         [=]() { qDebug() << "strumDwn triggered"; } );

QPushButton *pushButton m= new DualActionPushButton(this);
pushButton->addAction(strumNotesUpAction);
pushButton->addAction(strumNotesDnAction);
// insert into your tool bar

About

Just codefiles that can be read on both Linux-in-a-box, and Win10 on Desktop.. πŸ™„

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published