The key class here is QHostAddress as follows:
main.cpp
#include <QHostAddress>
#include <QTextStream>
#include <QString>
int main()
{
QTextStream standardOutput(stdout);
// You could use this, too:
// standardOutput.setIntegerBase(16);
// standardOutPut.setNumberFlags(QTextStream::ShowBase);
quint32 ipAddress = QHostAddress("192.168.1.1").toIPv4Address();
QString hexIpAddress = QString::number(ipAddress, 16);
QString prefixedUppercaseHexIpAddress = QString("0x%1")
.arg(uppercaseHexIpAddress);
standardOutput << prefixedUppercaseHexIpAddress;
return 0;
}
main.pro
TEMPLATE = app
TARGET = main
QT = core network
SOURCES += main.cpp
Build and Run
qmake && make && ./main
Output
0xC0A80101