i am trying to use QShortcut, and declare in in widget constructor like:
QShortcut *keyCtrlL;
keyCtrlL = new QShortcut(this);
keyCtrlL->setKey(Qt::CTRL + Qt::Key_L);
connect(keyCtrlL, &QShortcut::activated, this, &MyPage::loadB);
I am not sure it will work, even it compile fine, as variable is local in the constructor. So i am trying to declare it as a private variable for the whole class MyPage,
and getting compilation errors:
error: cannot initialize a parameter of type 'QWidget *' with an rvalue of type 'MyPage *'
ui->setupUi(this);
^~~~
./qt/forms/ui_mypage.h:69:27: note: passing argument to parameter 'MyPage' here
void setupUi(QWidget *MyPage)
^
qt/mypage.cpp:153:20: error: no matching constructor for initialization of 'QShortcut'
keyCtrlL = new QShortcut(this);
Even MyPage is inherited from QWidget. Why this error happens, how can i fix it?
You may be missing
#include
ofMyPage
header... Without it, it cannot upcastMyPage*
toQWidget*
. Check if it is not missing.