user12991669
user12991669

Reputation:

How to convert an unsigned long long to QString

I am trying to convert an unsigned long long to QString by using QString::number(). But it's giving me the following error "call of overloaded 'number(long long unsigned int*&)' is ambiguous. Can anyone help me?

EDIT

GetBoardSN(0, SN);
ui->tableWidget_Ethernet->setItem(0,2,new QTableWidgetItem(QString::number(SN)));

Header file : int GetBoardSN(int instance, unsigned long long *SN);

Upvotes: 0

Views: 2706

Answers (1)

T3 H40
T3 H40

Reputation: 2436

Your SN seems to be a pointer (unsigned long long *). Otherwise you would not be able to call GetBoardSN that way. So your code assumes the variable to have two different types. GetBoardSN requires SN to be a unsigned long long* pointer, String::number() requires SN to be a value for example of type unsigned long long.

To solve this, depending on your context, you can either declare SN as a non-pointer type and call GetBoardSn with a reference to this instance:

GetBoardSN(0, &SN);
ui->tableWidget_Ethernet->setItem(0,2,new QTableWidgetItem(QString::number(SN)));

or keep the pointer type and resolve the pointer before accessing its value:

GetBoardSN(0, SN);
ui->tableWidget_Ethernet->setItem(0,2,new QTableWidgetItem(QString::number(*SN)));

Which one is the better solution depends on your overall usage of SN.

Upvotes: 1

Related Questions