Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
src_corelib_text_qbytearrayview.cpp
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
#include <QtCore/qbytearrayview.h>
4
6
void
myfun1
(
QByteArrayView
bv);
// preferred
7
void
myfun2
(
const
QByteArrayView
&bv);
// compiles and works, but slower
9
11
void
fun
(
QByteArrayView
bv);
12
void
fun
(
char
ch
) {
fun
(
QByteArrayView
(&
ch
, 1)); }
14
16
QByteArrayView
str
(
"FF"
);
17
bool
ok
;
18
int
hex
=
str
.
toInt
(&
ok
, 16);
// hex == 255, ok == true
19
int
dec
=
str
.
toInt
(&
ok
, 10);
// dec == 0, ok == false
21
23
QByteArrayView
str
(
"FF"
);
24
bool
ok
;
25
long
hex
=
str
.
toLong
(&
ok
, 16);
// hex == 255, ok == true
26
long
dec
=
str
.
toLong
(&
ok
, 10);
// dec == 0, ok == false
28
30
QByteArrayView
string
(
"1234.56 Volt"
);
31
bool
ok
;
32
float
a
=
str
.
toFloat
(&
ok
);
// a == 0, ok == false
33
a
=
string
.first(7).toFloat(&
ok
);
// a == 1234.56, ok == true
QByteArrayView
Definition
qbytearrayview.h:75
QByteArrayView::toInt
int toInt(bool *ok=nullptr, int base=10) const
Definition
qbytearrayview.h:225
QByteArrayView::toFloat
float toFloat(bool *ok=nullptr) const
Definition
qbytearrayview.h:237
QByteArrayView::toLong
long toLong(bool *ok=nullptr, int base=10) const
Definition
qbytearrayview.h:229
a
GLboolean GLboolean GLboolean GLboolean a
[7]
Definition
qopengles2ext.h:337
ch
char ch
Definition
src_corelib_io_qtextstream.cpp:30
ok
bool ok
[2]
Definition
src_corelib_text_qbytearrayview.cpp:17
dec
int dec
Definition
src_corelib_text_qbytearrayview.cpp:19
str
QByteArrayView str("FF")
[1]
string
QByteArrayView string("1234.56 Volt")
[3]
hex
int hex
Definition
src_corelib_text_qbytearrayview.cpp:18
myfun1
void myfun1(QByteArrayView bv)
[0]
myfun2
void myfun2(const QByteArrayView &bv)
fun
QJSValue fun
[0]
Definition
src_script_qjsengine.cpp:11
qtbase
src
corelib
doc
snippets
code
src_corelib_text_qbytearrayview.cpp
Generated by
1.9.7