pazduha
pazduha

Reputation: 147

Pointer to QVector of pointers

I have a pointer to the QVector of pointers. I need to pass "trigger" as a reference.

I have this in header:

public:
    QVector<Trigger*>* triggers;

What do I have to input where ??? are (triggers[i] is not ok):

void FastViveLoop::solveTriggers()
{
    for(int i = 0; i < triggers->count(); ++i)
    {
        bool on, off;
        on = checkOn(???);        
    }
}

bool FastViveLoop::checkOn(Trigger &trigger)
{


    return false;
}

Upvotes: 0

Views: 757

Answers (1)

Tomaz Canabrava
Tomaz Canabrava

Reputation: 2398

I don't like that you are storing a QVector as a pointer, this is not how this class should be used. But since you are, there's an easy way to solve your issue.

void FastViveLoop::solveTriggers()
{
    for(auto item : (*trigger))
    {
        bool on, off;
        on = checkOn(item);        
    }
}

Use use the range-based for with the value of the QVector.

Upvotes: 1

Related Questions