No you cannot pass QString
to SLOT
macro. But you can use QString
for connect
. Also connect
cannot take QString
, so you have to convert it to const char *
. Simple example is:
QString slotName = SLOT(clicked());
connect(ui->pushButton, SIGNAL(clicked()), qPrintable(slotName));
SLOT
just stringifies passed parameter and concatenate it with 1
:
# define SLOT(a) qFlagLocation("1"#a QLOCATION)
If you don't want to use SLOT
it's possible to write code like this:
QString slotName = QString::number(QSLOT_CODE) + "clicked()";