Click here to Skip to main content
15,885,729 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem with understanding the following line of code:

static_cast<void(QButtonGroup::*)(QAbstractButton *, bool)>(&QButtonGroup::m_buttonGroup)


What I have tried:

I searched for the static_cast, and understand it, i know that in this code we are trying to convert the object
(&QButtonGroup::m_buttonGroup)

to another type:
<void(QButtonGroup::*)(QAbstractButton *, bool)>

But i do not understand the previous line.what do we mean by:
void(QButtonGroup::*)(QAbstractButton *, bool)

this supposed to be a type, but i can not get it?
Thanks in advance.
Posted
Updated 14-Aug-18 6:34am
v2

1 solution

C++
static_cast<void(QButtonGroup::*)(QAbstractButton *, bool)>(&QButtonGroup::m_buttonGroup)

Starting from the wrong end look at whatever is in the parentheses:
C++
&QButtonGroup::m_buttonGroup

m_buttonGroup is a static object, in the QButtonGroup class. And the & means use the address of this object. So that is the original item that is to be cast, to whatever is in the angle brackets (< >). The angle brackets contain:
C++
void(QButtonGroup::*)(QAbstractButton *, bool)
Which is a function pointer definition. The (QButtonGroup::*) part says this is a pointer to something in the QButtonGroup class. The parentheses around this tell us it's a function rather than a data pointer. The following parentheses contain the definition of the parameters to be passed to the function, and the preceding void part tells us that the function does not have a return type.

Without more context it's not possible to say more.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900