qvariant.html 130 KB
Newer Older
xuebingbing's avatar
xuebingbing committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qvariant.cpp -->
  <title>QVariant Class | Qt Core 5.11</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QVariant</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.11.2 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#a-note-on-gui-types">A Note on GUI Types</a></li>
<li class="level2"><a href="#using-canconvert-and-convert-consecutively">Using canConvert() and convert() Consecutively</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QVariant Class</h1>
<!-- $$$QVariant-brief -->
<p>The <a href="qvariant.html">QVariant</a> class acts like a union for the most common Qt data types. <a href="#details">More...</a></p>
<!-- @@@QVariant -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QVariant&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr></table></div><ul>
<li><a href="qvariant-members.html">List of all members, including inherited members</a></li>
<li><a href="qvariant-obsolete.html">Obsolete members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qvariant-handler.html">Handler</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qvariant-private.html">Private</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qvariant-privateshared.html">PrivateShared</a></b></td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant">QVariant</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-1">QVariant</a></b>(QVariant::Type <i>type</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-36">QVariant</a></b>(const QRegularExpression &amp;<i>re</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-37">QVariant</a></b>(const QUrl &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-38">QVariant</a></b>(const QEasingCurve &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-39">QVariant</a></b>(const QUuid &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-40">QVariant</a></b>(const QJsonValue &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-41">QVariant</a></b>(const QJsonObject &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-42">QVariant</a></b>(const QJsonArray &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-43">QVariant</a></b>(const QJsonDocument &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-44">QVariant</a></b>(const QModelIndex &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-45">QVariant</a></b>(const QPersistentModelIndex &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-46">QVariant</a></b>(QVariant &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-2">QVariant</a></b>(int <i>typeId</i>, const void *<i>copy</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-4">QVariant</a></b>(const QVariant &amp;<i>p</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-5">QVariant</a></b>(QDataStream &amp;<i>s</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-6">QVariant</a></b>(int <i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-7">QVariant</a></b>(uint <i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-8">QVariant</a></b>(qlonglong <i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-9">QVariant</a></b>(qulonglong <i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-10">QVariant</a></b>(bool <i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-11">QVariant</a></b>(double <i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-12">QVariant</a></b>(float <i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-13">QVariant</a></b>(const char *<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-14">QVariant</a></b>(const QByteArray &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-15">QVariant</a></b>(const QBitArray &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-16">QVariant</a></b>(const QString &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-17">QVariant</a></b>(QLatin1String <i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-18">QVariant</a></b>(const QStringList &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-19">QVariant</a></b>(QChar <i>c</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-20">QVariant</a></b>(const QDate &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-21">QVariant</a></b>(const QTime &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-22">QVariant</a></b>(const QDateTime &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-23">QVariant</a></b>(const QList&lt;QVariant&gt; &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-24">QVariant</a></b>(const QMap&lt;QString, QVariant&gt; &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-25">QVariant</a></b>(const QHash&lt;QString, QVariant&gt; &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-26">QVariant</a></b>(const QSize &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-27">QVariant</a></b>(const QSizeF &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-28">QVariant</a></b>(const QPoint &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-29">QVariant</a></b>(const QPointF &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-30">QVariant</a></b>(const QLine &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-31">QVariant</a></b>(const QLineF &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-32">QVariant</a></b>(const QRect &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-33">QVariant</a></b>(const QRectF &amp;<i>val</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-34">QVariant</a></b>(const QLocale &amp;<i>l</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariant-35">QVariant</a></b>(const QRegExp &amp;<i>regExp</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#dtor.QVariant">~QVariant</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#canConvert">canConvert</a></b>(int <i>targetTypeId</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#canConvert-1">canConvert</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#clear">clear</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#convert">convert</a></b>(int <i>targetTypeId</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#isNull">isNull</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#isValid">isValid</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#setValue">setValue</a></b>(const T &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#swap">swap</a></b>(QVariant &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QBitArray </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toBitArray">toBitArray</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toBool">toBool</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toByteArray">toByteArray</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QChar </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toChar">toChar</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDate </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toDate">toDate</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDateTime </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toDateTime">toDateTime</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> double </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toDouble">toDouble</a></b>(bool *<i>ok</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QEasingCurve </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toEasingCurve">toEasingCurve</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toFloat">toFloat</a></b>(bool *<i>ok</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QHash&lt;QString, QVariant&gt; </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toHash">toHash</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toInt">toInt</a></b>(bool *<i>ok</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJsonArray </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toJsonArray">toJsonArray</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJsonDocument </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toJsonDocument">toJsonDocument</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJsonObject </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toJsonObject">toJsonObject</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJsonValue </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toJsonValue">toJsonValue</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLine </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toLine">toLine</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLineF </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toLineF">toLineF</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QVariant&gt; </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toList">toList</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLocale </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toLocale">toLocale</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qlonglong </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toLongLong">toLongLong</a></b>(bool *<i>ok</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMap&lt;QString, QVariant&gt; </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toMap">toMap</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toModelIndex">toModelIndex</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPersistentModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toPersistentModelIndex">toPersistentModelIndex</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toPoint">toPoint</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPointF </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toPointF">toPointF</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toReal">toReal</a></b>(bool *<i>ok</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toRect">toRect</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRectF </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toRectF">toRectF</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRegExp </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toRegExp">toRegExp</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRegularExpression </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toRegularExpression">toRegularExpression</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toSize">toSize</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSizeF </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toSizeF">toSizeF</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toString">toString</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toStringList">toStringList</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTime </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toTime">toTime</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toUInt">toUInt</a></b>(bool *<i>ok</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qulonglong </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toULongLong">toULongLong</a></b>(bool *<i>ok</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toUrl">toUrl</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUuid </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#toUuid">toUuid</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant::Type </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#type">type</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const char *</td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#typeName">typeName</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#userType">userType</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#value">value</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-not-eq">operator!=</a></b>(const QVariant &amp;<i>v</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-lt">operator&lt;</a></b>(const QVariant &amp;<i>v</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-lt-eq">operator&lt;=</a></b>(const QVariant &amp;<i>v</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-eq">operator=</a></b>(const QVariant &amp;<i>variant</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-eq-1">operator=</a></b>(QVariant &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-eq-eq">operator==</a></b>(const QVariant &amp;<i>v</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-gt">operator&gt;</a></b>(const QVariant &amp;<i>v</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-gt-eq">operator&gt;=</a></b>(const QVariant &amp;<i>v</i>) const</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#fromStdVariant">fromStdVariant</a></b>(const int &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#fromValue">fromValue</a></b>(const T &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant::Type </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#nameToType">nameToType</a></b>(const char *<i>name</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const char *</td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#typeToName">typeToName</a></b>(int <i>typeId</i>)</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariantHash-typedef">QVariantHash</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariantList-typedef">QVariantList</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#QVariantMap-typedef">QVariantMap</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#qvariant_cast">qvariant_cast</a></b>(const QVariant &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-not-eq-1">operator!=</a></b>(const QVariant &amp;<i>v1</i>, const QVariant &amp;<i>v2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvariant.html#operator-eq-eq-1">operator==</a></b>(const QVariant &amp;<i>v1</i>, const QVariant &amp;<i>v2</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QVariant-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qvariant.html">QVariant</a> class acts like a union for the most common Qt data types.</p>
<p>Because C++ forbids unions from including types that have non-default constructors or destructors, most interesting Qt classes cannot be used in unions. Without <a href="qvariant.html">QVariant</a>, this would be a problem for <a href="qobject.html#property">QObject::property</a>() and for database work, etc.</p>
<p>A <a href="qvariant.html">QVariant</a> object holds a single value of a single <a href="qvariant.html#type">type</a>() at a time. (Some <a href="qvariant.html#type">type</a>()s are multi-valued, for example a string list.) You can find out what type, T, the variant holds, convert it to a different type using <a href="qvariant.html#convert">convert</a>(), get its value using one of the toT() functions (e.g&#x2e;, <a href="qvariant.html#toSize">toSize</a>()) and check whether the type can be converted to a particular type using <a href="qvariant.html#canConvert-1">canConvert</a>().</p>
<p>The methods named toT() (e.g&#x2e;, <a href="qvariant.html#toInt">toInt</a>(), <a href="qvariant.html#toString">toString</a>()) are const. If you ask for the stored type, they return a copy of the stored object. If you ask for a type that can be generated from the stored type, toT() copies and converts and leaves the object itself unchanged. If you ask for a type that cannot be generated from the stored type, the result depends on the type; see the function documentation for details.</p>
<p>Here is some example code to demonstrate the use of <a href="qvariant.html">QVariant</a>:</p>
<pre class="cpp">

  <span class="type"><a href="qdatastream.html">QDataStream</a></span> out(<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>);
  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> v(<span class="number">123</span>);                <span class="comment">// The variant now contains an int</span>
  <span class="type">int</span> x <span class="operator">=</span> v<span class="operator">.</span>toInt();              <span class="comment">// x = 123</span>
  out <span class="operator">&lt;</span><span class="operator">&lt;</span> v;                       <span class="comment">// Writes a type tag and an int to out</span>
  v <span class="operator">=</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>(<span class="string">&quot;hello&quot;</span>);          <span class="comment">// The variant now contains a QByteArray</span>
  v <span class="operator">=</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>(tr(<span class="string">&quot;hello&quot;</span>));      <span class="comment">// The variant now contains a QString</span>
  <span class="type">int</span> y <span class="operator">=</span> v<span class="operator">.</span>toInt();              <span class="comment">// y = 0 since v cannot be converted to an int</span>
  <span class="type"><a href="qstring.html">QString</a></span> s <span class="operator">=</span> v<span class="operator">.</span>toString();       <span class="comment">// s = tr(&quot;hello&quot;)  (see QObject::tr())</span>
  out <span class="operator">&lt;</span><span class="operator">&lt;</span> v;                       <span class="comment">// Writes a type tag and a QString to out</span>
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="qdatastream.html">QDataStream</a></span> in(<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>);            <span class="comment">// (opening the previously written stream)</span>
  in <span class="operator">&gt;</span><span class="operator">&gt;</span> v;                        <span class="comment">// Reads an Int variant</span>
  <span class="type">int</span> z <span class="operator">=</span> v<span class="operator">.</span>toInt();              <span class="comment">// z = 123</span>
  <a href="qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;Type is %s&quot;</span><span class="operator">,</span>            <span class="comment">// prints &quot;Type is int&quot;</span>
          v<span class="operator">.</span>typeName());
  v <span class="operator">=</span> v<span class="operator">.</span>toInt() <span class="operator">+</span> <span class="number">100</span>;            <span class="comment">// The variant now hold the value 223</span>
  v <span class="operator">=</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>(<span class="type"><a href="qstringlist.html">QStringList</a></span>());

</pre>
<p>You can even store <a href="qlist.html">QList</a>&lt;<a href="qvariant.html">QVariant</a>&gt; and <a href="qmap.html">QMap</a>&lt;<a href="qstring.html">QString</a>, <a href="qvariant.html">QVariant</a>&gt; values in a variant, so you can easily construct arbitrarily complex data structures of arbitrary types. This is very powerful and versatile, but may prove less memory and speed efficient than storing specific types in standard data structures.</p>
<p><a href="qvariant.html">QVariant</a> also supports the notion of null values, where you can have a defined type with no value set. However, note that <a href="qvariant.html">QVariant</a> types can only be cast when they have had a value set.</p>
<pre class="cpp">

  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> x<span class="operator">,</span> y(<span class="type"><a href="qstring.html">QString</a></span>())<span class="operator">,</span> z(<span class="type"><a href="qstring.html">QString</a></span>(<span class="string">&quot;&quot;</span>));
  x<span class="operator">.</span>convert(<span class="type"><a href="qvariant.html#QVariant">QVariant</a></span><span class="operator">::</span>Int);
  <span class="comment">// x.isNull() == true</span>
  <span class="comment">// y.isNull() == true, z.isNull() == false</span>

</pre>
<p><a href="qvariant.html">QVariant</a> can be extended to support other types than those mentioned in the <a href="qvariant-obsolete.html#Type-enum">Type</a> enum. See <a href="custom-types.html">Creating Custom Qt Types</a> for details.</p>
<a name="a-note-on-gui-types"></a>
<h3 >A Note on GUI Types</h3>
<p>Because <a href="qvariant.html">QVariant</a> is part of the Qt Core module, it cannot provide conversion functions to data types defined in Qt GUI, such as <a href="../qtgui/qcolor.html">QColor</a>, <a href="../qtgui/qimage.html">QImage</a>, and <a href="../qtgui/qpixmap.html">QPixmap</a>. In other words, there is no <code>toColor()</code> function. Instead, you can use the <a href="qvariant.html#value">QVariant::value</a>() or the <a href="qvariant.html#qvariant_cast">qvariant_cast</a>() template function. For example:</p>
<pre class="cpp">

  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> variant;
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="../qtgui/qcolor.html">QColor</a></span> color <span class="operator">=</span> variant<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type"><a href="../qtgui/qcolor.html">QColor</a></span><span class="operator">&gt;</span>();

</pre>
<p>The inverse conversion (e.g&#x2e;, from <a href="../qtgui/qcolor.html">QColor</a> to <a href="qvariant.html">QVariant</a>) is automatic for all data types supported by <a href="qvariant.html">QVariant</a>, including GUI-related types:</p>
<pre class="cpp">

  <span class="type"><a href="../qtgui/qcolor.html">QColor</a></span> color <span class="operator">=</span> palette()<span class="operator">.</span>background()<span class="operator">.</span>color();
  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> variant <span class="operator">=</span> color;

</pre>
<a name="using-canconvert-and-convert-consecutively"></a>
<h3 >Using canConvert() and convert() Consecutively</h3>
<p>When using <a href="qvariant.html#canConvert-1">canConvert</a>() and <a href="qvariant.html#convert">convert</a>() consecutively, it is possible for <a href="qvariant.html#canConvert-1">canConvert</a>() to return true, but <a href="qvariant.html#convert">convert</a>() to return false. This is typically because <a href="qvariant.html#canConvert-1">canConvert</a>() only reports the general ability of <a href="qvariant.html">QVariant</a> to convert between types given suitable data; it is still possible to supply data which cannot actually be converted.</p>
<p>For example, <a href="qvariant.html#canConvert">canConvert</a>(Int) would return true when called on a variant containing a string because, in principle, <a href="qvariant.html">QVariant</a> is able to convert strings of numbers to integers. However, if the string contains non-numeric characters, it cannot be converted to an integer, and any attempt to convert it will fail. Hence, it is important to have both functions return true for a successful conversion.</p>
</div>
<p><b>See also </b><a href="qmetatype.html">QMetaType</a>.</p>
<!-- @@@QVariant -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QVariant[overload1]$$$QVariant -->
<h3 class="fn" id="QVariant"><a name="QVariant"></a>QVariant::<span class="name">QVariant</span>()</h3>
<p>Constructs an invalid variant.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantQVariant::Type -->
<h3 class="fn" id="QVariant-1"><a name="QVariant-1"></a>QVariant::<span class="name">QVariant</span>(<span class="type"><a href="qvariant-obsolete.html#Type-enum">QVariant::Type</a></span> <i>type</i>)</h3>
<p>Constructs an uninitialized variant of type <i>type</i>. This will create a variant in a special null state that if accessed will return a default constructed value of the <i>type</i>.</p>
<p><b>See also </b><a href="qvariant.html#isNull">isNull</a>().</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQRegularExpression& -->
<h3 class="fn" id="QVariant-36"><a name="QVariant-36"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qregularexpression.html">QRegularExpression</a></span> &amp;<i>re</i>)</h3>
<p>Constructs a new variant with the regular expression value <i>re</i>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQUrl& -->
<h3 class="fn" id="QVariant-37"><a name="QVariant-37"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qurl.html">QUrl</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a url value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQEasingCurve& -->
<h3 class="fn" id="QVariant-38"><a name="QVariant-38"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qeasingcurve.html">QEasingCurve</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with an easing curve value, <i>val</i>.</p>
<p>This function was introduced in  Qt 4.7.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQUuid& -->
<h3 class="fn" id="QVariant-39"><a name="QVariant-39"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="quuid.html">QUuid</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with an uuid value, <i>val</i>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQJsonValue& -->
<h3 class="fn" id="QVariant-40"><a name="QVariant-40"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qjsonvalue.html">QJsonValue</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a json value, <i>val</i>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQJsonObject& -->
<h3 class="fn" id="QVariant-41"><a name="QVariant-41"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qjsonobject.html">QJsonObject</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a json object value, <i>val</i>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQJsonArray& -->
<h3 class="fn" id="QVariant-42"><a name="QVariant-42"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qjsonarray.html">QJsonArray</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a json array value, <i>val</i>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQJsonDocument& -->
<h3 class="fn" id="QVariant-43"><a name="QVariant-43"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qjsondocument.html">QJsonDocument</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a json document value, <i>val</i>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQModelIndex& -->
<h3 class="fn" id="QVariant-44"><a name="QVariant-44"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a <a href="qmodelindex.html">QModelIndex</a> value, <i>val</i>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQPersistentModelIndex& -->
<h3 class="fn" id="QVariant-45"><a name="QVariant-45"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qpersistentmodelindex.html">QPersistentModelIndex</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> value, <i>val</i>.</p>
<p>This function was introduced in  Qt 5.5.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantQVariant&& -->
<h3 class="fn" id="QVariant-46"><a name="QVariant-46"></a>QVariant::<span class="name">QVariant</span>(<span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-constructs a <a href="qvariant.html">QVariant</a> instance, making it point at the same object that <i>other</i> was pointing to.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantintconstvoid* -->
<h3 class="fn" id="QVariant-2"><a name="QVariant-2"></a>QVariant::<span class="name">QVariant</span>(<span class="type">int</span> <i>typeId</i>, const <span class="type">void</span> *<i>copy</i>)</h3>
<p>Constructs variant of type <i>typeId</i>, and initializes with <i>copy</i> if <i>copy</i> is not 0.</p>
<p>Note that you have to pass the address of the variable you want stored.</p>
<p>Usually, you never have to use this constructor, use <a href="qvariant.html#fromValue">QVariant::fromValue</a>() instead to construct variants from the pointer types represented by <code>QMetaType::VoidStar</code>, and <code>QMetaType::QObjectStar</code>.</p>
<p><b>See also </b><a href="qvariant.html#fromValue">QVariant::fromValue</a>() and <a href="qmetatype.html#Type-enum">QMetaType::Type</a>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQVariant& -->
<h3 class="fn" id="QVariant-4"><a name="QVariant-4"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>p</i>)</h3>
<p>Constructs a copy of the variant, <i>p</i>, passed as the argument to this constructor.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantQDataStream& -->
<h3 class="fn" id="QVariant-5"><a name="QVariant-5"></a>QVariant::<span class="name">QVariant</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>s</i>)</h3>
<p>Reads the variant from the data stream, <i>s</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantint -->
<h3 class="fn" id="QVariant-6"><a name="QVariant-6"></a>QVariant::<span class="name">QVariant</span>(<span class="type">int</span> <i>val</i>)</h3>
<p>Constructs a new variant with an integer value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantuint -->
<h3 class="fn" id="QVariant-7"><a name="QVariant-7"></a>QVariant::<span class="name">QVariant</span>(<span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>val</i>)</h3>
<p>Constructs a new variant with an unsigned integer value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantqlonglong -->
<h3 class="fn" id="QVariant-8"><a name="QVariant-8"></a>QVariant::<span class="name">QVariant</span>(<span class="type"><a href="qtglobal.html#qlonglong-typedef">qlonglong</a></span> <i>val</i>)</h3>
<p>Constructs a new variant with a long long integer value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantqulonglong -->
<h3 class="fn" id="QVariant-9"><a name="QVariant-9"></a>QVariant::<span class="name">QVariant</span>(<span class="type"><a href="qtglobal.html#qulonglong-typedef">qulonglong</a></span> <i>val</i>)</h3>
<p>Constructs a new variant with an unsigned long long integer value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantbool -->
<h3 class="fn" id="QVariant-10"><a name="QVariant-10"></a>QVariant::<span class="name">QVariant</span>(<span class="type">bool</span> <i>val</i>)</h3>
<p>Constructs a new variant with a boolean value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantdouble -->
<h3 class="fn" id="QVariant-11"><a name="QVariant-11"></a>QVariant::<span class="name">QVariant</span>(<span class="type">double</span> <i>val</i>)</h3>
<p>Constructs a new variant with a floating point value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantfloat -->
<h3 class="fn" id="QVariant-12"><a name="QVariant-12"></a>QVariant::<span class="name">QVariant</span>(<span class="type">float</span> <i>val</i>)</h3>
<p>Constructs a new variant with a floating point value, <i>val</i>.</p>
<p>This function was introduced in  Qt 4.6.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstchar* -->
<h3 class="fn" id="QVariant-13"><a name="QVariant-13"></a>QVariant::<span class="name">QVariant</span>(const <span class="type">char</span> *<i>val</i>)</h3>
<p>Constructs a new variant with a string value of <i>val</i>. The variant creates a deep copy of <i>val</i> into a <a href="qstring.html">QString</a> assuming UTF-8 encoding on the input <i>val</i>.</p>
<p>Note that <i>val</i> is converted to a <a href="qstring.html">QString</a> for storing in the variant and <a href="qvariant.html#userType">QVariant::userType</a>() will return <a href="qmetatype.html#Type-enum">QMetaType::QString</a> for the variant.</p>
<p>You can disable this operator by defining <code>QT_NO_CAST_FROM_ASCII</code> when you compile your applications.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQByteArray& -->
<h3 class="fn" id="QVariant-14"><a name="QVariant-14"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a bytearray value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQBitArray& -->
<h3 class="fn" id="QVariant-15"><a name="QVariant-15"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qbitarray.html">QBitArray</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a bitarray value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQString& -->
<h3 class="fn" id="QVariant-16"><a name="QVariant-16"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a string value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantQLatin1String -->
<h3 class="fn" id="QVariant-17"><a name="QVariant-17"></a>QVariant::<span class="name">QVariant</span>(<span class="type"><a href="qlatin1string.html">QLatin1String</a></span> <i>val</i>)</h3>
<p>Constructs a new variant with a string value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQStringList& -->
<h3 class="fn" id="QVariant-18"><a name="QVariant-18"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a string list value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantQChar -->
<h3 class="fn" id="QVariant-19"><a name="QVariant-19"></a>QVariant::<span class="name">QVariant</span>(<span class="type"><a href="qchar.html">QChar</a></span> <i>c</i>)</h3>
<p>Constructs a new variant with a char value, <i>c</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQDate& -->
<h3 class="fn" id="QVariant-20"><a name="QVariant-20"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qdate.html">QDate</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a date value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQTime& -->
<h3 class="fn" id="QVariant-21"><a name="QVariant-21"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qtime.html">QTime</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a time value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQDateTime& -->
<h3 class="fn" id="QVariant-22"><a name="QVariant-22"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qdatetime.html">QDateTime</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a date/time value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQList<QVariant>& -->
<h3 class="fn" id="QVariant-23"><a name="QVariant-23"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>&gt; &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a list value, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQMap<QString,QVariant>& -->
<h3 class="fn" id="QVariant-24"><a name="QVariant-24"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qmap.html">QMap</a></span>&lt;<span class="type"><a href="qstring.html">QString</a></span>, <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>&gt; &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a map of <a href="qvariant.html">QVariant</a>s, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQHash<QString,QVariant>& -->
<h3 class="fn" id="QVariant-25"><a name="QVariant-25"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qhash.html">QHash</a></span>&lt;<span class="type"><a href="qstring.html">QString</a></span>, <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>&gt; &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a hash of <a href="qvariant.html">QVariant</a>s, <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQSize& -->
<h3 class="fn" id="QVariant-26"><a name="QVariant-26"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qsize.html">QSize</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a size value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQSizeF& -->
<h3 class="fn" id="QVariant-27"><a name="QVariant-27"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qsizef.html">QSizeF</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a size value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQPoint& -->
<h3 class="fn" id="QVariant-28"><a name="QVariant-28"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a point value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQPointF& -->
<h3 class="fn" id="QVariant-29"><a name="QVariant-29"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qpointf.html">QPointF</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a point value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQLine& -->
<h3 class="fn" id="QVariant-30"><a name="QVariant-30"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qline.html">QLine</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a line value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQLineF& -->
<h3 class="fn" id="QVariant-31"><a name="QVariant-31"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qlinef.html">QLineF</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a line value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQRect& -->
<h3 class="fn" id="QVariant-32"><a name="QVariant-32"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qrect.html">QRect</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a rect value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQRectF& -->
<h3 class="fn" id="QVariant-33"><a name="QVariant-33"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qrectf.html">QRectF</a></span> &amp;<i>val</i>)</h3>
<p>Constructs a new variant with a rect value of <i>val</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQLocale& -->
<h3 class="fn" id="QVariant-34"><a name="QVariant-34"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qlocale.html">QLocale</a></span> &amp;<i>l</i>)</h3>
<p>Constructs a new variant with a locale value, <i>l</i>.</p>
<!-- @@@QVariant -->
<!-- $$$QVariant$$$QVariantconstQRegExp& -->
<h3 class="fn" id="QVariant-35"><a name="QVariant-35"></a>QVariant::<span class="name">QVariant</span>(const <span class="type"><a href="qregexp.html">QRegExp</a></span> &amp;<i>regExp</i>)</h3>
<p>Constructs a new variant with the regexp value <i>regExp</i>.</p>
<!-- @@@QVariant -->
<!-- $$$~QVariant[overload1]$$$~QVariant -->
<h3 class="fn" id="dtor.QVariant"><a name="dtor.QVariant"></a>QVariant::<span class="name">~QVariant</span>()</h3>
<p>Destroys the <a href="qvariant.html">QVariant</a> and the contained object.</p>
<p>Note that subclasses that reimplement <a href="qvariant.html#clear">clear</a>() should reimplement the destructor to call <a href="qvariant.html#clear">clear</a>(). This destructor calls <a href="qvariant.html#clear">clear</a>(), but because it is the destructor, <a href="qvariant.html#clear">QVariant::clear</a>() is called rather than a subclass's <a href="qvariant.html#clear">clear</a>().</p>
<!-- @@@~QVariant -->
<!-- $$$canConvert[overload1]$$$canConvertint -->
<h3 class="fn" id="canConvert"><a name="canConvert"></a><span class="type">bool</span> QVariant::<span class="name">canConvert</span>(<span class="type">int</span> <i>targetTypeId</i>) const</h3>
<p>Returns <code>true</code> if the variant's type can be cast to the requested type, <i>targetTypeId</i>. Such casting is done automatically when calling the <a href="qvariant.html#toInt">toInt</a>(), <a href="qvariant.html#toBool">toBool</a>(), ..&#x2e; methods.</p>
<p>The following casts are done automatically:</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Type</th><th >Automatically Cast To</th></tr></thead>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::Bool</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QUuid</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::QChar</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::QColor</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QString</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::QDate</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QDateTime</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::QDateTime</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QDate</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::QTime</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::Double</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::QFont</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QString</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::Int</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::QKeySequence</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::QVariantList</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QStringList</a> (if the list's items can be converted to QStrings)</td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::LongLong</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::QPoint</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QPointF</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::QRect</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QRectF</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::QString</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::QColor</a>, <a href="qmetatype.html#Type-enum">QMetaType::QDate</a>, <a href="qmetatype.html#Type-enum">QMetaType::QDateTime</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::QFont</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::QKeySequence</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QStringList</a>, <a href="qmetatype.html#Type-enum">QMetaType::QTime</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QUuid</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::QStringList</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QVariantList</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a> (if the list contains exactly one item)</td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::QTime</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QString</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::UInt</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a></td></tr>
<tr valign="top" class="even"><td ><a href="qmetatype.html#Type-enum">QMetaType::QUuid</a></td><td ><a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a></td></tr>
</table></div>
<p>A <a href="qvariant.html">QVariant</a> containing a pointer to a type derived from <a href="qobject.html">QObject</a> will also return true for this function if a <a href="qobject.html#qobject_cast">qobject_cast</a> to the type described by <i>targetTypeId</i> would succeed. Note that this only works for <a href="qobject.html">QObject</a> subclasses which use the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro.</p>
<p>A <a href="qvariant.html">QVariant</a> containing a sequential container will also return true for this function if the <i>targetTypeId</i> is <a href="qvariant.html#QVariantList-typedef">QVariantList</a>. It is possible to iterate over the contents of the container without extracting it as a (copied) <a href="qvariant.html#QVariantList-typedef">QVariantList</a>:</p>
<pre class="cpp">

  <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> intList <span class="operator">=</span> {<span class="number">7</span><span class="operator">,</span> <span class="number">11</span><span class="operator">,</span> <span class="number">42</span>};

  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> variant <span class="operator">=</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span><span class="operator">::</span>fromValue(intList);
  <span class="keyword">if</span> (variant<span class="operator">.</span>canConvert<span class="operator">&lt;</span><span class="type"><a href="qvariant.html#QVariantList-typedef">QVariantList</a></span><span class="operator">&gt;</span>()) {
      <span class="type"><a href="qsequentialiterable.html">QSequentialIterable</a></span> iterable <span class="operator">=</span> variant<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type"><a href="qsequentialiterable.html">QSequentialIterable</a></span><span class="operator">&gt;</span>();
      <span class="comment">// Can use foreach:</span>
      foreach (<span class="keyword">const</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> <span class="operator">&amp;</span>v<span class="operator">,</span> iterable) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> v;
      }
      <span class="comment">// Can use C++11 range-for:</span>
      <span class="keyword">for</span> (<span class="keyword">const</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> <span class="operator">&amp;</span>v : iterable) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> v;
      }
      <span class="comment">// Can use iterators:</span>
      <span class="type"><a href="qsequentialiterable.html">QSequentialIterable</a></span><span class="operator">::</span>const_iterator it <span class="operator">=</span> iterable<span class="operator">.</span>begin();
      <span class="keyword">const</span> <span class="type"><a href="qsequentialiterable.html">QSequentialIterable</a></span><span class="operator">::</span>const_iterator end <span class="operator">=</span> iterable<span class="operator">.</span>end();
      <span class="keyword">for</span> ( ; it <span class="operator">!</span><span class="operator">=</span> end; <span class="operator">+</span><span class="operator">+</span>it) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="operator">*</span>it;
      }
  }

</pre>
<p>This requires that the value_type of the container is itself a metatype.</p>
<p>Similarly, a <a href="qvariant.html">QVariant</a> containing a sequential container will also return true for this function the <i>targetTypeId</i> is <a href="qvariant.html#QVariantHash-typedef">QVariantHash</a> or <a href="qvariant.html#QVariantMap-typedef">QVariantMap</a>. It is possible to iterate over the contents of the container without extracting it as a (copied) <a href="qvariant.html#QVariantHash-typedef">QVariantHash</a> or <a href="qvariant.html#QVariantMap-typedef">QVariantMap</a>:</p>
<pre class="cpp">

  <span class="type"><a href="qhash.html">QHash</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">,</span> <span class="type"><a href="qstring.html">QString</a></span><span class="operator">&gt;</span> mapping;
  mapping<span class="operator">.</span>insert(<span class="number">7</span><span class="operator">,</span> <span class="string">&quot;Seven&quot;</span>);
  mapping<span class="operator">.</span>insert(<span class="number">11</span><span class="operator">,</span> <span class="string">&quot;Eleven&quot;</span>);
  mapping<span class="operator">.</span>insert(<span class="number">42</span><span class="operator">,</span> <span class="string">&quot;Forty-two&quot;</span>);

  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> variant <span class="operator">=</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span><span class="operator">::</span>fromValue(mapping);
  <span class="keyword">if</span> (variant<span class="operator">.</span>canConvert<span class="operator">&lt;</span><span class="type"><a href="qvariant.html#QVariantHash-typedef">QVariantHash</a></span><span class="operator">&gt;</span>()) {
      <span class="type"><a href="qassociativeiterable.html">QAssociativeIterable</a></span> iterable <span class="operator">=</span> variant<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type"><a href="qassociativeiterable.html">QAssociativeIterable</a></span><span class="operator">&gt;</span>();
      <span class="comment">// Can use foreach over the values:</span>
      foreach (<span class="keyword">const</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> <span class="operator">&amp;</span>v<span class="operator">,</span> iterable) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> v;
      }
      <span class="comment">// Can use C++11 range-for over the values:</span>
      <span class="keyword">for</span> (<span class="keyword">const</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> <span class="operator">&amp;</span>v : iterable) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> v;
      }
      <span class="comment">// Can use iterators:</span>
      <span class="type"><a href="qassociativeiterable.html">QAssociativeIterable</a></span><span class="operator">::</span>const_iterator it <span class="operator">=</span> iterable<span class="operator">.</span>begin();
      <span class="keyword">const</span> <span class="type"><a href="qassociativeiterable.html">QAssociativeIterable</a></span><span class="operator">::</span>const_iterator end <span class="operator">=</span> iterable<span class="operator">.</span>end();
      <span class="keyword">for</span> ( ; it <span class="operator">!</span><span class="operator">=</span> end; <span class="operator">+</span><span class="operator">+</span>it) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="operator">*</span>it; <span class="comment">// The current value</span>
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> it<span class="operator">.</span>key();
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> it<span class="operator">.</span>value();
      }
  }

</pre>
<p><b>See also </b><a href="qvariant.html#convert">convert</a>(), <a href="qsequentialiterable.html">QSequentialIterable</a>, <a href="qmetatype.html#Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE">Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE</a>(), <a href="qassociativeiterable.html">QAssociativeIterable</a>, and <a href="qmetatype.html#Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE">Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE</a>().</p>
<!-- @@@canConvert -->
<!-- $$$canConvert$$$canConvert -->
<h3 class="fn" id="canConvert-1"><a name="canConvert-1"></a><span class="type">bool</span> QVariant::<span class="name">canConvert</span>() const</h3>
<p>Returns <code>true</code> if the variant can be converted to the template type <code>T</code>, otherwise false.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> v <span class="operator">=</span> <span class="number">42</span>;

  v<span class="operator">.</span>canConvert<span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span>();              <span class="comment">// returns true</span>
  v<span class="operator">.</span>canConvert<span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">&gt;</span>();          <span class="comment">// returns true</span>

  MyCustomStruct s;
  v<span class="operator">.</span>setValue(s);

  v<span class="operator">.</span>canConvert<span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span>();              <span class="comment">// returns false</span>
  v<span class="operator">.</span>canConvert<span class="operator">&lt;</span>MyCustomStruct<span class="operator">&gt;</span>();   <span class="comment">// returns true</span>

</pre>
<p>A <a href="qvariant.html">QVariant</a> containing a pointer to a type derived from <a href="qobject.html">QObject</a> will also return true for this function if a <a href="qobject.html#qobject_cast">qobject_cast</a> to the template type <code>T</code> would succeed. Note that this only works for <a href="qobject.html">QObject</a> subclasses which use the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro.</p>
<p><b>See also </b><a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@canConvert -->
<!-- $$$clear[overload1]$$$clear -->
<h3 class="fn" id="clear"><a name="clear"></a><span class="type">void</span> QVariant::<span class="name">clear</span>()</h3>
<p>Convert this variant to type <a href="qmetatype.html#Type-enum">QMetaType::UnknownType</a> and free up any resources used.</p>
<!-- @@@clear -->
<!-- $$$convert[overload1]$$$convertint -->
<h3 class="fn" id="convert"><a name="convert"></a><span class="type">bool</span> QVariant::<span class="name">convert</span>(<span class="type">int</span> <i>targetTypeId</i>)</h3>
<p>Casts the variant to the requested type, <i>targetTypeId</i>. If the cast cannot be done, the variant is still changed to the requested type, but is left in a cleared null state similar to that constructed by <a href="qvariant.html">QVariant</a>(Type).</p>
<p>Returns <code>true</code> if the current type of the variant was successfully cast; otherwise returns <code>false</code>.</p>
<p>A <a href="qvariant.html">QVariant</a> containing a pointer to a type derived from <a href="qobject.html">QObject</a> will also convert and return true for this function if a <a href="qobject.html#qobject_cast">qobject_cast</a> to the type described by <i>targetTypeId</i> would succeed. Note that this only works for <a href="qobject.html">QObject</a> subclasses which use the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro.</p>
<p><b>Note: </b>converting QVariants that are null due to not being initialized or having failed a previous conversion will always fail, changing the type, remaining null, and returning <code>false</code>.</p><p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#clear">clear</a>().</p>
<!-- @@@convert -->
<!-- $$$fromStdVariant[overload1]$$$fromStdVariantconstint& -->
<h3 class="fn" id="fromStdVariant"><a name="fromStdVariant"></a><code>[static] </code><span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> QVariant::<span class="name">fromStdVariant</span>(const <span class="type">int</span> &amp;<i>value</i>)</h3>
<p>Returns a <a href="qvariant.html">QVariant</a> with the type and value of the active variant of <i>value</i>. If the active type is std::monostate a default <a href="qvariant.html">QVariant</a> is returned.</p>
<p><b>Note: </b>With this method you do not need to register the variant as a Qt metatype, since the std::variant is resolved before being stored. The component types should be registered however.</p><p>This function was introduced in  Qt 5.11.</p>
<p><b>See also </b><a href="qvariant.html#fromValue">fromValue</a>().</p>
<!-- @@@fromStdVariant -->
<!-- $$$fromValue[overload1]$$$fromValueconstT& -->
<h3 class="fn" id="fromValue"><a name="fromValue"></a><code>[static] </code><span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> QVariant::<span class="name">fromValue</span>(const <span class="type">T</span> &amp;<i>value</i>)</h3>
<p>Returns a <a href="qvariant.html">QVariant</a> containing a copy of <i>value</i>. Behaves exactly like <a href="qvariant.html#setValue">setValue</a>() otherwise.</p>
<p>Example:</p>
<pre class="cpp">

  MyCustomStruct s;
  <span class="keyword">return</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span><span class="operator">::</span>fromValue(s);

</pre>
<p><b>Note: </b>If you are working with custom types, you should use the <a href="qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE</a>() macro to register your custom type.</p><p><b>See also </b><a href="qvariant.html#setValue">setValue</a>() and <a href="qvariant.html#value">value</a>().</p>
<!-- @@@fromValue -->
<!-- $$$isNull[overload1]$$$isNull -->
<h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QVariant::<span class="name">isNull</span>() const</h3>
<p>Returns <code>true</code> if this is a null variant, false otherwise. A variant is considered null if it contains no initialized value, or the contained value is a null pointer or is an instance of a built-in type that has an isNull method, in which case the result would be the same as calling isNull on the wrapped object.</p>
<p><b>Warning:</b> Null variants is not a single state and two null variants may easily return <code>false</code> on the == operator if they do not contain similar null values.</p>
<p><b>See also </b><a href="qvariant.html#convert">convert</a>(int).</p>
<!-- @@@isNull -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QVariant::<span class="name">isValid</span>() const</h3>
<p>Returns <code>true</code> if the storage type of this variant is not <a href="qmetatype.html#Type-enum">QMetaType::UnknownType</a>; otherwise returns <code>false</code>.</p>
<!-- @@@isValid -->
<!-- $$$nameToType[overload1]$$$nameToTypeconstchar* -->
<h3 class="fn" id="nameToType"><a name="nameToType"></a><code>[static] </code><span class="type"><a href="qvariant-obsolete.html#Type-enum">QVariant::Type</a></span> QVariant::<span class="name">nameToType</span>(const <span class="type">char</span> *<i>name</i>)</h3>
<p>Converts the string representation of the storage type given in <i>name</i>, to its enum representation.</p>
<p>If the string representation cannot be converted to any enum representation, the variant is set to <code>Invalid</code>.</p>
<!-- @@@nameToType -->
<!-- $$$setValue[overload1]$$$setValueconstT& -->
<h3 class="fn" id="setValue"><a name="setValue"></a><span class="type">void</span> QVariant::<span class="name">setValue</span>(const <span class="type">T</span> &amp;<i>value</i>)</h3>
<p>Stores a copy of <i>value</i>. If <code>T</code> is a type that <a href="qvariant.html">QVariant</a> doesn't support, <a href="qmetatype.html">QMetaType</a> is used to store the value. A compile error will occur if <a href="qmetatype.html">QMetaType</a> doesn't handle the type.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> v;

  v<span class="operator">.</span>setValue(<span class="number">5</span>);
  <span class="type">int</span> i <span class="operator">=</span> v<span class="operator">.</span>toInt();         <span class="comment">// i is now 5</span>
  <span class="type"><a href="qstring.html">QString</a></span> s <span class="operator">=</span> v<span class="operator">.</span>toString()   <span class="comment">// s is now &quot;5&quot;</span>

  MyCustomStruct c;
  v<span class="operator">.</span>setValue(c);

  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

  MyCustomStruct c2 <span class="operator">=</span> v<span class="operator">.</span>value<span class="operator">&lt;</span>MyCustomStruct<span class="operator">&gt;</span>();

</pre>
<p><b>See also </b><a href="qvariant.html#value">value</a>(), <a href="qvariant.html#fromValue">fromValue</a>(), and <a href="qvariant.html#canConvert-1">canConvert</a>().</p>
<!-- @@@setValue -->
<!-- $$$swap[overload1]$$$swapQVariant& -->
<h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QVariant::<span class="name">swap</span>(<span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>other</i>)</h3>
<p>Swaps variant <i>other</i> with this variant. This operation is very fast and never fails.</p>
<p>This function was introduced in  Qt 4.8.</p>
<!-- @@@swap -->
<!-- $$$toBitArray[overload1]$$$toBitArray -->
<h3 class="fn" id="toBitArray"><a name="toBitArray"></a><span class="type"><a href="qbitarray.html">QBitArray</a></span> QVariant::<span class="name">toBitArray</span>() const</h3>
<p>Returns the variant as a <a href="qbitarray.html">QBitArray</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QBitArray</a>; otherwise returns an empty bit array.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toBitArray -->
<!-- $$$toBool[overload1]$$$toBool -->
<h3 class="fn" id="toBool"><a name="toBool"></a><span class="type">bool</span> QVariant::<span class="name">toBool</span>() const</h3>
<p>Returns the variant as a bool if the variant has <a href="qvariant.html#userType">userType</a>() Bool.</p>
<p>Returns <code>true</code> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, or <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a> and the value is non-zero, or if the variant has type <a href="qmetatype.html#Type-enum">QMetaType::QString</a> or <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a> and its lower-case content is not one of the following: empty, &quot;0&quot; or &quot;false&quot;; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toBool -->
<!-- $$$toByteArray[overload1]$$$toByteArray -->
<h3 class="fn" id="toByteArray"><a name="toByteArray"></a><span class="type"><a href="qbytearray.html">QByteArray</a></span> QVariant::<span class="name">toByteArray</span>() const</h3>
<p>Returns the variant as a <a href="qbytearray.html">QByteArray</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a> or <a href="qmetatype.html#Type-enum">QMetaType::QString</a> (converted using <a href="qstring.html#fromUtf8">QString::fromUtf8</a>()); otherwise returns an empty byte array.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toByteArray -->
<!-- $$$toChar[overload1]$$$toChar -->
<h3 class="fn" id="toChar"><a name="toChar"></a><span class="type"><a href="qchar.html">QChar</a></span> QVariant::<span class="name">toChar</span>() const</h3>
<p>Returns the variant as a <a href="qchar.html">QChar</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, or <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>; otherwise returns an invalid <a href="qchar.html">QChar</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toChar -->
<!-- $$$toDate[overload1]$$$toDate -->
<h3 class="fn" id="toDate"><a name="toDate"></a><span class="type"><a href="qdate.html">QDate</a></span> QVariant::<span class="name">toDate</span>() const</h3>
<p>Returns the variant as a <a href="qdate.html">QDate</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QDate</a>, <a href="qmetatype.html#Type-enum">QMetaType::QDateTime</a>, or <a href="qmetatype.html#Type-enum">QMetaType::QString</a>; otherwise returns an invalid date.</p>
<p>If the <a href="qvariant.html#type">type</a>() is <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, an invalid date will be returned if the string cannot be parsed as a <a href="qt.html#DateFormat-enum">Qt::ISODate</a> format date.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toDate -->
<!-- $$$toDateTime[overload1]$$$toDateTime -->
<h3 class="fn" id="toDateTime"><a name="toDateTime"></a><span class="type"><a href="qdatetime.html">QDateTime</a></span> QVariant::<span class="name">toDateTime</span>() const</h3>
<p>Returns the variant as a <a href="qdatetime.html">QDateTime</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QDateTime</a>, <a href="qmetatype.html#Type-enum">QMetaType::QDate</a>, or <a href="qmetatype.html#Type-enum">QMetaType::QString</a>; otherwise returns an invalid date/time.</p>
<p>If the <a href="qvariant.html#type">type</a>() is <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, an invalid date/time will be returned if the string cannot be parsed as a <a href="qt.html#DateFormat-enum">Qt::ISODate</a> format date/time.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toDateTime -->
<!-- $$$toDouble[overload1]$$$toDoublebool* -->
<h3 class="fn" id="toDouble"><a name="toDouble"></a><span class="type">double</span> QVariant::<span class="name">toDouble</span>(<span class="type">bool</span> *<i>ok</i> = nullptr) const</h3>
<p>Returns the variant as a double if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Float</a>, <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, or <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>; otherwise returns 0.0&#x2e;</p>
<p>If <i>ok</i> is non-null: <code>*</code><i>ok</i> is set to true if the value could be converted to a double; otherwise <code>*</code><i>ok</i> is set to false.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toDouble -->
<!-- $$$toEasingCurve[overload1]$$$toEasingCurve -->
<h3 class="fn" id="toEasingCurve"><a name="toEasingCurve"></a><span class="type"><a href="qeasingcurve.html">QEasingCurve</a></span> QVariant::<span class="name">toEasingCurve</span>() const</h3>
<p>Returns the variant as a <a href="qeasingcurve.html">QEasingCurve</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QEasingCurve</a>; otherwise returns a default easing curve.</p>
<p>This function was introduced in  Qt 4.7.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toEasingCurve -->
<!-- $$$toFloat[overload1]$$$toFloatbool* -->
<h3 class="fn" id="toFloat"><a name="toFloat"></a><span class="type">float</span> QVariant::<span class="name">toFloat</span>(<span class="type">bool</span> *<i>ok</i> = nullptr) const</h3>
<p>Returns the variant as a float if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Float</a>, <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, or <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>; otherwise returns 0.0&#x2e;</p>
<p>If <i>ok</i> is non-null: <code>*</code><i>ok</i> is set to true if the value could be converted to a double; otherwise <code>*</code><i>ok</i> is set to false.</p>
<p>This function was introduced in  Qt 4.6.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toFloat -->
<!-- $$$toHash[overload1]$$$toHash -->
<h3 class="fn" id="toHash"><a name="toHash"></a><span class="type"><a href="qhash.html">QHash</a></span>&lt;<span class="type"><a href="qstring.html">QString</a></span>, <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>&gt; QVariant::<span class="name">toHash</span>() const</h3>
<p>Returns the variant as a <a href="qhash.html#qhash">QHash</a>&lt;<a href="qstring.html">QString</a>, <a href="qvariant.html">QVariant</a>&gt; if the variant has <a href="qvariant.html#type">type</a>() <a href="qmetatype.html#Type-enum">QMetaType::QVariantHash</a>; otherwise returns an empty map.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toHash -->
<!-- $$$toInt[overload1]$$$toIntbool* -->
<h3 class="fn" id="toInt"><a name="toInt"></a><span class="type">int</span> QVariant::<span class="name">toInt</span>(<span class="type">bool</span> *<i>ok</i> = nullptr) const</h3>
<p>Returns the variant as an int if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, or <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>; otherwise returns 0.</p>
<p>If <i>ok</i> is non-null: <code>*</code><i>ok</i> is set to true if the value could be converted to an int; otherwise <code>*</code><i>ok</i> is set to false.</p>
<p><b>Warning:</b> If the value is convertible to a <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a> but is too large to be represented in an int, the resulting arithmetic overflow will not be reflected in <i>ok</i>. A simple workaround is to use <a href="qstring.html#toInt">QString::toInt</a>().</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toInt -->
<!-- $$$toJsonArray[overload1]$$$toJsonArray -->
<h3 class="fn" id="toJsonArray"><a name="toJsonArray"></a><span class="type"><a href="qjsonarray.html">QJsonArray</a></span> QVariant::<span class="name">toJsonArray</span>() const</h3>
<p>Returns the variant as a <a href="qjsonarray.html">QJsonArray</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qjsonarray.html">QJsonArray</a>; otherwise returns a default constructed <a href="qjsonarray.html">QJsonArray</a>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toJsonArray -->
<!-- $$$toJsonDocument[overload1]$$$toJsonDocument -->
<h3 class="fn" id="toJsonDocument"><a name="toJsonDocument"></a><span class="type"><a href="qjsondocument.html">QJsonDocument</a></span> QVariant::<span class="name">toJsonDocument</span>() const</h3>
<p>Returns the variant as a <a href="qjsondocument.html">QJsonDocument</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qjsondocument.html">QJsonDocument</a>; otherwise returns a default constructed <a href="qjsondocument.html">QJsonDocument</a>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toJsonDocument -->
<!-- $$$toJsonObject[overload1]$$$toJsonObject -->
<h3 class="fn" id="toJsonObject"><a name="toJsonObject"></a><span class="type"><a href="qjsonobject.html">QJsonObject</a></span> QVariant::<span class="name">toJsonObject</span>() const</h3>
<p>Returns the variant as a <a href="qjsonobject.html">QJsonObject</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qjsonobject.html">QJsonObject</a>; otherwise returns a default constructed <a href="qjsonobject.html">QJsonObject</a>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toJsonObject -->
<!-- $$$toJsonValue[overload1]$$$toJsonValue -->
<h3 class="fn" id="toJsonValue"><a name="toJsonValue"></a><span class="type"><a href="qjsonvalue.html">QJsonValue</a></span> QVariant::<span class="name">toJsonValue</span>() const</h3>
<p>Returns the variant as a <a href="qjsonvalue.html">QJsonValue</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qjsonvalue.html">QJsonValue</a>; otherwise returns a default constructed <a href="qjsonvalue.html">QJsonValue</a>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toJsonValue -->
<!-- $$$toLine[overload1]$$$toLine -->
<h3 class="fn" id="toLine"><a name="toLine"></a><span class="type"><a href="qline.html">QLine</a></span> QVariant::<span class="name">toLine</span>() const</h3>
<p>Returns the variant as a <a href="qline.html">QLine</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QLine</a>; otherwise returns an invalid <a href="qline.html">QLine</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toLine -->
<!-- $$$toLineF[overload1]$$$toLineF -->
<h3 class="fn" id="toLineF"><a name="toLineF"></a><span class="type"><a href="qlinef.html">QLineF</a></span> QVariant::<span class="name">toLineF</span>() const</h3>
<p>Returns the variant as a <a href="qlinef.html">QLineF</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QLineF</a>; otherwise returns an invalid <a href="qlinef.html">QLineF</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toLineF -->
<!-- $$$toList[overload1]$$$toList -->
<h3 class="fn" id="toList"><a name="toList"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>&gt; QVariant::<span class="name">toList</span>() const</h3>
<p>Returns the variant as a <a href="qvariant.html#QVariantList-typedef">QVariantList</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QVariantList</a> or <a href="qmetatype.html#Type-enum">QMetaType::QStringList</a>; otherwise returns an empty list.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toList -->
<!-- $$$toLocale[overload1]$$$toLocale -->
<h3 class="fn" id="toLocale"><a name="toLocale"></a><span class="type"><a href="qlocale.html">QLocale</a></span> QVariant::<span class="name">toLocale</span>() const</h3>
<p>Returns the variant as a <a href="qlocale.html">QLocale</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QLocale</a>; otherwise returns an invalid <a href="qlocale.html">QLocale</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toLocale -->
<!-- $$$toLongLong[overload1]$$$toLongLongbool* -->
<h3 class="fn" id="toLongLong"><a name="toLongLong"></a><span class="type"><a href="qtglobal.html#qlonglong-typedef">qlonglong</a></span> QVariant::<span class="name">toLongLong</span>(<span class="type">bool</span> *<i>ok</i> = nullptr) const</h3>
<p>Returns the variant as a long long int if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, or <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>; otherwise returns 0.</p>
<p>If <i>ok</i> is non-null: <code>*</code><code>ok</code> is set to true if the value could be converted to an int; otherwise <code>*</code><code>ok</code> is set to false.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toLongLong -->
<!-- $$$toMap[overload1]$$$toMap -->
<h3 class="fn" id="toMap"><a name="toMap"></a><span class="type"><a href="qmap.html">QMap</a></span>&lt;<span class="type"><a href="qstring.html">QString</a></span>, <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span>&gt; QVariant::<span class="name">toMap</span>() const</h3>
<p>Returns the variant as a <a href="qmap.html">QMap</a>&lt;<a href="qstring.html">QString</a>, <a href="qvariant.html">QVariant</a>&gt; if the variant has <a href="qvariant.html#type">type</a>() <a href="qmetatype.html#Type-enum">QMetaType::QVariantMap</a>; otherwise returns an empty map.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toMap -->
<!-- $$$toModelIndex[overload1]$$$toModelIndex -->
<h3 class="fn" id="toModelIndex"><a name="toModelIndex"></a><span class="type"><a href="qmodelindex.html">QModelIndex</a></span> QVariant::<span class="name">toModelIndex</span>() const</h3>
<p>Returns the variant as a <a href="qmodelindex.html">QModelIndex</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmodelindex.html">QModelIndex</a>; otherwise returns a default constructed <a href="qmodelindex.html">QModelIndex</a>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId), <a href="qvariant.html#convert">convert</a>(), and <a href="qvariant.html#toPersistentModelIndex">toPersistentModelIndex</a>().</p>
<!-- @@@toModelIndex -->
<!-- $$$toPersistentModelIndex[overload1]$$$toPersistentModelIndex -->
<h3 class="fn" id="toPersistentModelIndex"><a name="toPersistentModelIndex"></a><span class="type"><a href="qpersistentmodelindex.html">QPersistentModelIndex</a></span> QVariant::<span class="name">toPersistentModelIndex</span>() const</h3>
<p>Returns the variant as a <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qpersistentmodelindex.html">QPersistentModelIndex</a>; otherwise returns a default constructed <a href="qpersistentmodelindex.html">QPersistentModelIndex</a>.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId), <a href="qvariant.html#convert">convert</a>(), and <a href="qvariant.html#toModelIndex">toModelIndex</a>().</p>
<!-- @@@toPersistentModelIndex -->
<!-- $$$toPoint[overload1]$$$toPoint -->
<h3 class="fn" id="toPoint"><a name="toPoint"></a><span class="type"><a href="qpoint.html">QPoint</a></span> QVariant::<span class="name">toPoint</span>() const</h3>
<p>Returns the variant as a <a href="qpoint.html">QPoint</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QPoint</a> or <a href="qmetatype.html#Type-enum">QMetaType::QPointF</a>; otherwise returns a null <a href="qpoint.html">QPoint</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toPoint -->
<!-- $$$toPointF[overload1]$$$toPointF -->
<h3 class="fn" id="toPointF"><a name="toPointF"></a><span class="type"><a href="qpointf.html">QPointF</a></span> QVariant::<span class="name">toPointF</span>() const</h3>
<p>Returns the variant as a <a href="qpointf.html">QPointF</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QPoint</a> or <a href="qmetatype.html#Type-enum">QMetaType::QPointF</a>; otherwise returns a null <a href="qpointf.html">QPointF</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toPointF -->
<!-- $$$toReal[overload1]$$$toRealbool* -->
<h3 class="fn" id="toReal"><a name="toReal"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QVariant::<span class="name">toReal</span>(<span class="type">bool</span> *<i>ok</i> = nullptr) const</h3>
<p>Returns the variant as a qreal if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Float</a>, <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, or <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>; otherwise returns 0.0&#x2e;</p>
<p>If <i>ok</i> is non-null: <code>*</code><i>ok</i> is set to true if the value could be converted to a double; otherwise <code>*</code><i>ok</i> is set to false.</p>
<p>This function was introduced in  Qt 4.6.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toReal -->
<!-- $$$toRect[overload1]$$$toRect -->
<h3 class="fn" id="toRect"><a name="toRect"></a><span class="type"><a href="qrect.html">QRect</a></span> QVariant::<span class="name">toRect</span>() const</h3>
<p>Returns the variant as a <a href="qrect.html">QRect</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QRect</a>; otherwise returns an invalid <a href="qrect.html">QRect</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toRect -->
<!-- $$$toRectF[overload1]$$$toRectF -->
<h3 class="fn" id="toRectF"><a name="toRectF"></a><span class="type"><a href="qrectf.html">QRectF</a></span> QVariant::<span class="name">toRectF</span>() const</h3>
<p>Returns the variant as a <a href="qrectf.html">QRectF</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QRect</a> or <a href="qmetatype.html#Type-enum">QMetaType::QRectF</a>; otherwise returns an invalid <a href="qrectf.html">QRectF</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toRectF -->
<!-- $$$toRegExp[overload1]$$$toRegExp -->
<h3 class="fn" id="toRegExp"><a name="toRegExp"></a><span class="type"><a href="qregexp.html">QRegExp</a></span> QVariant::<span class="name">toRegExp</span>() const</h3>
<p>Returns the variant as a <a href="qregexp.html">QRegExp</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QRegExp</a>; otherwise returns an empty <a href="qregexp.html">QRegExp</a>.</p>
<p>This function was introduced in  Qt 4.1.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toRegExp -->
<!-- $$$toRegularExpression[overload1]$$$toRegularExpression -->
<h3 class="fn" id="toRegularExpression"><a name="toRegularExpression"></a><span class="type"><a href="qregularexpression.html">QRegularExpression</a></span> QVariant::<span class="name">toRegularExpression</span>() const</h3>
<p>Returns the variant as a <a href="qregularexpression.html">QRegularExpression</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qregularexpression.html">QRegularExpression</a>; otherwise returns an empty <a href="qregularexpression.html">QRegularExpression</a>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toRegularExpression -->
<!-- $$$toSize[overload1]$$$toSize -->
<h3 class="fn" id="toSize"><a name="toSize"></a><span class="type"><a href="qsize.html">QSize</a></span> QVariant::<span class="name">toSize</span>() const</h3>
<p>Returns the variant as a <a href="qsize.html">QSize</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QSize</a>; otherwise returns an invalid <a href="qsize.html">QSize</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toSize -->
<!-- $$$toSizeF[overload1]$$$toSizeF -->
<h3 class="fn" id="toSizeF"><a name="toSizeF"></a><span class="type"><a href="qsizef.html">QSizeF</a></span> QVariant::<span class="name">toSizeF</span>() const</h3>
<p>Returns the variant as a <a href="qsizef.html">QSizeF</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QSizeF</a>; otherwise returns an invalid <a href="qsizef.html">QSizeF</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toSizeF -->
<!-- $$$toString[overload1]$$$toString -->
<h3 class="fn" id="toString"><a name="toString"></a><span class="type"><a href="qstring.html">QString</a></span> QVariant::<span class="name">toString</span>() const</h3>
<p>Returns the variant as a <a href="qstring.html">QString</a> if the variant has a <a href="qvariant.html#userType">userType</a>() including, but not limited to:</p>
<p><a href="qmetatype.html#Type-enum">QMetaType::QString</a>, <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::QDate</a>, <a href="qmetatype.html#Type-enum">QMetaType::QDateTime</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QStringList</a>, <a href="qmetatype.html#Type-enum">QMetaType::QTime</a>, <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, or <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>.</p>
<p>Calling QVariant::toString() on an unsupported variant returns an empty string.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toString -->
<!-- $$$toStringList[overload1]$$$toStringList -->
<h3 class="fn" id="toStringList"><a name="toStringList"></a><span class="type"><a href="qstringlist.html">QStringList</a></span> QVariant::<span class="name">toStringList</span>() const</h3>
<p>Returns the variant as a <a href="qstringlist.html">QStringList</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QStringList</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, or <a href="qmetatype.html#Type-enum">QMetaType::QVariantList</a> of a type that can be converted to <a href="qstring.html">QString</a>; otherwise returns an empty list.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toStringList -->
<!-- $$$toTime[overload1]$$$toTime -->
<h3 class="fn" id="toTime"><a name="toTime"></a><span class="type"><a href="qtime.html">QTime</a></span> QVariant::<span class="name">toTime</span>() const</h3>
<p>Returns the variant as a <a href="qtime.html">QTime</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QTime</a>, <a href="qmetatype.html#Type-enum">QMetaType::QDateTime</a>, or <a href="qmetatype.html#Type-enum">QMetaType::QString</a>; otherwise returns an invalid time.</p>
<p>If the <a href="qvariant.html#type">type</a>() is <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, an invalid time will be returned if the string cannot be parsed as a <a href="qt.html#DateFormat-enum">Qt::ISODate</a> format time.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toTime -->
<!-- $$$toUInt[overload1]$$$toUIntbool* -->
<h3 class="fn" id="toUInt"><a name="toUInt"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> QVariant::<span class="name">toUInt</span>(<span class="type">bool</span> *<i>ok</i> = nullptr) const</h3>
<p>Returns the variant as an unsigned int if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>, <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, or <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>; otherwise returns 0.</p>
<p>If <i>ok</i> is non-null: <code>*</code><i>ok</i> is set to true if the value could be converted to an unsigned int; otherwise <code>*</code><i>ok</i> is set to false.</p>
<p><b>Warning:</b> If the value is convertible to a <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a> but is too large to be represented in an unsigned int, the resulting arithmetic overflow will not be reflected in <i>ok</i>. A simple workaround is to use <a href="qstring.html#toUInt">QString::toUInt</a>().</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toUInt -->
<!-- $$$toULongLong[overload1]$$$toULongLongbool* -->
<h3 class="fn" id="toULongLong"><a name="toULongLong"></a><span class="type"><a href="qtglobal.html#qulonglong-typedef">qulonglong</a></span> QVariant::<span class="name">toULongLong</span>(<span class="type">bool</span> *<i>ok</i> = nullptr) const</h3>
<p>Returns the variant as an unsigned long long int if the variant has <a href="qvariant.html#type">type</a>() <a href="qmetatype.html#Type-enum">QMetaType::ULongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::Bool</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a>, <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, <a href="qmetatype.html#Type-enum">QMetaType::Double</a>, <a href="qmetatype.html#Type-enum">QMetaType::Int</a>, <a href="qmetatype.html#Type-enum">QMetaType::LongLong</a>, <a href="qmetatype.html#Type-enum">QMetaType::QString</a>, or <a href="qmetatype.html#Type-enum">QMetaType::UInt</a>; otherwise returns 0.</p>
<p>If <i>ok</i> is non-null: <code>*</code><i>ok</i> is set to true if the value could be converted to an int; otherwise <code>*</code><i>ok</i> is set to false.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toULongLong -->
<!-- $$$toUrl[overload1]$$$toUrl -->
<h3 class="fn" id="toUrl"><a name="toUrl"></a><span class="type"><a href="qurl.html">QUrl</a></span> QVariant::<span class="name">toUrl</span>() const</h3>
<p>Returns the variant as a <a href="qurl.html">QUrl</a> if the variant has <a href="qvariant.html#userType">userType</a>() <a href="qmetatype.html#Type-enum">QMetaType::QUrl</a>; otherwise returns an invalid <a href="qurl.html">QUrl</a>.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toUrl -->
<!-- $$$toUuid[overload1]$$$toUuid -->
<h3 class="fn" id="toUuid"><a name="toUuid"></a><span class="type"><a href="quuid.html">QUuid</a></span> QVariant::<span class="name">toUuid</span>() const</h3>
<p>Returns the variant as a <a href="quuid.html">QUuid</a> if the variant has <a href="qvariant.html#type">type</a>() <a href="qmetatype.html#Type-enum">QMetaType::QUuid</a>, <a href="qmetatype.html#Type-enum">QMetaType::QByteArray</a> or <a href="qmetatype.html#Type-enum">QMetaType::QString</a>; otherwise returns a default-constructed <a href="quuid.html">QUuid</a>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qvariant.html#canConvert">canConvert</a>(int targetTypeId) and <a href="qvariant.html#convert">convert</a>().</p>
<!-- @@@toUuid -->
<!-- $$$type[overload1]$$$type -->
<h3 class="fn" id="type"><a name="type"></a><span class="type"><a href="qvariant-obsolete.html#Type-enum">QVariant::Type</a></span> QVariant::<span class="name">type</span>() const</h3>
<p>Returns the storage type of the value stored in the variant. Although this function is declared as returning QVariant::Type, the return value should be interpreted as <a href="qmetatype.html#Type-enum">QMetaType::Type</a>. In particular, QVariant::UserType is returned here only if the value is equal or greater than <a href="qmetatype.html#Type-enum">QMetaType::User</a>.</p>
<p>Note that return values in the ranges QVariant::Char through QVariant::RegExp and QVariant::Font through QVariant::Transform correspond to the values in the ranges <a href="qmetatype.html#Type-enum">QMetaType::QChar</a> through <a href="qmetatype.html#Type-enum">QMetaType::QRegExp</a> and <a href="qmetatype.html#Type-enum">QMetaType::QFont</a> through <a href="qmetatype.html#Type-enum">QMetaType::QQuaternion</a>.</p>
<p>Pay particular attention when working with char and <a href="qchar.html">QChar</a> variants. Note that there is no <a href="qvariant.html">QVariant</a> constructor specifically for type char, but there is one for <a href="qchar.html">QChar</a>. For a variant of type <a href="qchar.html">QChar</a>, this function returns QVariant::Char, which is the same as <a href="qmetatype.html#Type-enum">QMetaType::QChar</a>, but for a variant of type <code>char</code>, this function returns <a href="qmetatype.html#Type-enum">QMetaType::Char</a>, which is <i>not</i> the same as QVariant::Char.</p>
<p>Also note that the types <code>void*</code>, <code>long</code>, <code>short</code>, <code>unsigned</code> <code>long</code>, <code>unsigned</code> <code>short</code>, <code>unsigned</code> <code>char</code>, <code>float</code>, <code>QObject*</code>, and <code>QWidget*</code> are represented in <a href="qmetatype.html#Type-enum">QMetaType::Type</a> but not in QVariant::Type, and they can be returned by this function. However, they are considered to be user defined types when tested against QVariant::Type.</p>
<p>To test whether an instance of <a href="qvariant.html">QVariant</a> contains a data type that is compatible with the data type you are interested in, use <a href="qvariant.html#canConvert-1">canConvert</a>().</p>
<!-- @@@type -->
<!-- $$$typeName[overload1]$$$typeName -->
<h3 class="fn" id="typeName"><a name="typeName"></a>const <span class="type">char</span> *QVariant::<span class="name">typeName</span>() const</h3>
<p>Returns the name of the type stored in the variant. The returned strings describe the C++ datatype used to store the data: for example, &quot;<a href="../qtgui/qfont.html">QFont</a>&quot;, &quot;<a href="qstring.html">QString</a>&quot;, or &quot;<a href="qvariant.html#QVariantList-typedef">QVariantList</a>&quot;. An Invalid variant returns 0.</p>
<!-- @@@typeName -->
<!-- $$$typeToName[overload1]$$$typeToNameint -->
<h3 class="fn" id="typeToName"><a name="typeToName"></a><code>[static] </code>const <span class="type">char</span> *QVariant::<span class="name">typeToName</span>(<span class="type">int</span> <i>typeId</i>)</h3>
<p>Converts the int representation of the storage type, <i>typeId</i>, to its string representation.</p>
<p>Returns a null pointer if the type is <a href="qmetatype.html#Type-enum">QMetaType::UnknownType</a> or doesn't exist.</p>
<!-- @@@typeToName -->
<!-- $$$userType[overload1]$$$userType -->
<h3 class="fn" id="userType"><a name="userType"></a><span class="type">int</span> QVariant::<span class="name">userType</span>() const</h3>
<p>Returns the storage type of the value stored in the variant. For non-user types, this is the same as <a href="qvariant.html#type">type</a>().</p>
<p><b>See also </b><a href="qvariant.html#type">type</a>().</p>
<!-- @@@userType -->
<!-- $$$value[overload1]$$$value -->
<h3 class="fn" id="value"><a name="value"></a><span class="type">T</span> QVariant::<span class="name">value</span>() const</h3>
<p>Returns the stored value converted to the template type <code>T</code>. Call <a href="qvariant.html#canConvert-1">canConvert</a>() to find out whether a type can be converted. If the value cannot be converted, a <a href="containers.html#default-constructed-value">default-constructed value</a> will be returned.</p>
<p>If the type <code>T</code> is supported by <a href="qvariant.html">QVariant</a>, this function behaves exactly as <a href="qvariant.html#toString">toString</a>(), <a href="qvariant.html#toInt">toInt</a>() etc.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> v;

  MyCustomStruct c;
  <span class="keyword">if</span> (v<span class="operator">.</span>canConvert<span class="operator">&lt;</span>MyCustomStruct<span class="operator">&gt;</span>())
      c <span class="operator">=</span> v<span class="operator">.</span>value<span class="operator">&lt;</span>MyCustomStruct<span class="operator">&gt;</span>();

  v <span class="operator">=</span> <span class="number">7</span>;
  <span class="type">int</span> i <span class="operator">=</span> v<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span>();                        <span class="comment">// same as v.toInt()</span>
  <span class="type"><a href="qstring.html">QString</a></span> s <span class="operator">=</span> v<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">&gt;</span>();                <span class="comment">// same as v.toString(), s is now &quot;7&quot;</span>
  MyCustomStruct c2 <span class="operator">=</span> v<span class="operator">.</span>value<span class="operator">&lt;</span>MyCustomStruct<span class="operator">&gt;</span>(); <span class="comment">// conversion failed, c2 is empty</span>

</pre>
<p>If the <a href="qvariant.html">QVariant</a> contains a pointer to a type derived from <a href="qobject.html">QObject</a> then <code>T</code> may be any <a href="qobject.html">QObject</a> type. If the pointer stored in the <a href="qvariant.html">QVariant</a> can be <a href="qobject.html#qobject_cast">qobject_cast</a> to T, then that result is returned. Otherwise a null pointer is returned. Note that this only works for <a href="qobject.html">QObject</a> subclasses which use the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro.</p>
<p>If the <a href="qvariant.html">QVariant</a> contains a sequential container and <code>T</code> is <a href="qvariant.html#QVariantList-typedef">QVariantList</a>, the elements of the container will be converted into <a href="qvariant.html">QVariant</a>s and returned as a <a href="qvariant.html#QVariantList-typedef">QVariantList</a>.</p>
<pre class="cpp">

  <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> intList <span class="operator">=</span> {<span class="number">7</span><span class="operator">,</span> <span class="number">11</span><span class="operator">,</span> <span class="number">42</span>};

  <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> variant <span class="operator">=</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span><span class="operator">::</span>fromValue(intList);
  <span class="keyword">if</span> (variant<span class="operator">.</span>canConvert<span class="operator">&lt;</span><span class="type"><a href="qvariant.html#QVariantList-typedef">QVariantList</a></span><span class="operator">&gt;</span>()) {
      <span class="type"><a href="qsequentialiterable.html">QSequentialIterable</a></span> iterable <span class="operator">=</span> variant<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type"><a href="qsequentialiterable.html">QSequentialIterable</a></span><span class="operator">&gt;</span>();
      <span class="comment">// Can use foreach:</span>
      foreach (<span class="keyword">const</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> <span class="operator">&amp;</span>v<span class="operator">,</span> iterable) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> v;
      }
      <span class="comment">// Can use C++11 range-for:</span>
      <span class="keyword">for</span> (<span class="keyword">const</span> <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> <span class="operator">&amp;</span>v : iterable) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> v;
      }
      <span class="comment">// Can use iterators:</span>
      <span class="type"><a href="qsequentialiterable.html">QSequentialIterable</a></span><span class="operator">::</span>const_iterator it <span class="operator">=</span> iterable<span class="operator">.</span>begin();
      <span class="keyword">const</span> <span class="type"><a href="qsequentialiterable.html">QSequentialIterable</a></span><span class="operator">::</span>const_iterator end <span class="operator">=</span> iterable<span class="operator">.</span>end();
      <span class="keyword">for</span> ( ; it <span class="operator">!</span><span class="operator">=</span> end; <span class="operator">+</span><span class="operator">+</span>it) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="operator">*</span>it;
      }
  }

</pre>
<p><b>See also </b><a href="qvariant.html#setValue">setValue</a>(), <a href="qvariant.html#fromValue">fromValue</a>(), <a href="qvariant.html#canConvert-1">canConvert</a>(), and <a href="qmetatype.html#Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE">Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE</a>().</p>
<!-- @@@value -->
<!-- $$$operator!=[overload1]$$$operator!=constQVariant& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QVariant::<span class="name">operator!=</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v</i>) const</h3>
<p>Compares this <a href="qvariant.html">QVariant</a> with <i>v</i> and returns <code>true</code> if they are not equal; otherwise returns <code>false</code>.</p>
<p><b>Warning:</b> To make this function work with a custom type registered with <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), its comparison operator must be registered using <a href="qmetatype.html#registerComparators">QMetaType::registerComparators</a>().</p>
<!-- @@@operator!= -->
<!-- $$$operator<[overload1]$$$operator<constQVariant& -->
<h3 class="fn" id="operator-lt"><a name="operator-lt"></a><span class="type">bool</span> QVariant::<span class="name">operator&lt;</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v</i>) const</h3>
<p>Compares this <a href="qvariant.html">QVariant</a> with <i>v</i> and returns <code>true</code> if this is less than <i>v</i>.</p>
<p><b>Note: </b>Comparability might not be availabe for the type stored in this <a href="qvariant.html">QVariant</a> or in <i>v</i>.</p><p><b>Warning:</b> To make this function work with a custom type registered with <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), its comparison operator must be registered using <a href="qmetatype.html#registerComparators">QMetaType::registerComparators</a>().</p>
<!-- @@@operator< -->
<!-- $$$operator<=[overload1]$$$operator<=constQVariant& -->
<h3 class="fn" id="operator-lt-eq"><a name="operator-lt-eq"></a><span class="type">bool</span> QVariant::<span class="name">operator&lt;=</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v</i>) const</h3>
<p>Compares this <a href="qvariant.html">QVariant</a> with <i>v</i> and returns <code>true</code> if this is less or equal than <i>v</i>.</p>
<p><b>Note: </b>Comparability might not be available for the type stored in this <a href="qvariant.html">QVariant</a> or in <i>v</i>.</p><p><b>Warning:</b> To make this function work with a custom type registered with <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), its comparison operator must be registered using <a href="qmetatype.html#registerComparators">QMetaType::registerComparators</a>().</p>
<!-- @@@operator<= -->
<!-- $$$operator=[overload1]$$$operator=constQVariant& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;QVariant::<span class="name">operator=</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>variant</i>)</h3>
<p>Assigns the value of the variant <i>variant</i> to this variant.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=QVariant&& -->
<h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;QVariant::<span class="name">operator=</span>(<span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-assigns <i>other</i> to this <a href="qvariant.html">QVariant</a> instance.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@operator= -->
<!-- $$$operator==[overload1]$$$operator==constQVariant& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QVariant::<span class="name">operator==</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v</i>) const</h3>
<p>Compares this <a href="qvariant.html">QVariant</a> with <i>v</i> and returns <code>true</code> if they are equal; otherwise returns <code>false</code>.</p>
<p><a href="qvariant.html">QVariant</a> uses the equality operator of the <a href="qvariant.html#type">type</a>() it contains to check for equality. <a href="qvariant.html">QVariant</a> will try to <a href="qvariant.html#convert">convert</a>() <i>v</i> if its type is not the same as this variant's type. See <a href="qvariant.html#canConvert-1">canConvert</a>() for a list of possible conversions.</p>
<p><b>Warning:</b> To make this function work with a custom type registered with <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), its comparison operator must be registered using <a href="qmetatype.html#registerComparators">QMetaType::registerComparators</a>().</p>
<!-- @@@operator== -->
<!-- $$$operator>[overload1]$$$operator>constQVariant& -->
<h3 class="fn" id="operator-gt"><a name="operator-gt"></a><span class="type">bool</span> QVariant::<span class="name">operator&gt;</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v</i>) const</h3>
<p>Compares this <a href="qvariant.html">QVariant</a> with <i>v</i> and returns <code>true</code> if this is larger than <i>v</i>.</p>
<p><b>Note: </b>Comparability might not be available for the type stored in this <a href="qvariant.html">QVariant</a> or in <i>v</i>.</p><p><b>Warning:</b> To make this function work with a custom type registered with <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), its comparison operator must be registered using <a href="qmetatype.html#registerComparators">QMetaType::registerComparators</a>().</p>
<!-- @@@operator> -->
<!-- $$$operator>=[overload1]$$$operator>=constQVariant& -->
<h3 class="fn" id="operator-gt-eq"><a name="operator-gt-eq"></a><span class="type">bool</span> QVariant::<span class="name">operator&gt;=</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v</i>) const</h3>
<p>Compares this <a href="qvariant.html">QVariant</a> with <i>v</i> and returns <code>true</code> if this is larger or equal than <i>v</i>.</p>
<p><b>Note: </b>Comparability might not be available for the type stored in this <a href="qvariant.html">QVariant</a> or in <i>v</i>.</p><p><b>Warning:</b> To make this function work with a custom type registered with <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), its comparison operator must be registered using <a href="qmetatype.html#registerComparators">QMetaType::registerComparators</a>().</p>
<!-- @@@operator>= -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$QVariantHash -->
<h3 class="fn" id="QVariantHash-typedef"><a name="QVariantHash-typedef"></a>typedef <span class="name">QVariantHash</span></h3>
<p>Synonym for <a href="qhash.html#qhash">QHash</a>&lt;<a href="qstring.html">QString</a>, <a href="qvariant.html">QVariant</a>&gt;.</p>
<p>This typedef was introduced in  Qt 4.5.</p>
<!-- @@@QVariantHash -->
<!-- $$$QVariantList -->
<h3 class="fn" id="QVariantList-typedef"><a name="QVariantList-typedef"></a>typedef <span class="name">QVariantList</span></h3>
<p>Synonym for <a href="qlist.html">QList</a>&lt;<a href="qvariant.html">QVariant</a>&gt;.</p>
<!-- @@@QVariantList -->
<!-- $$$QVariantMap -->
<h3 class="fn" id="QVariantMap-typedef"><a name="QVariantMap-typedef"></a>typedef <span class="name">QVariantMap</span></h3>
<p>Synonym for <a href="qmap.html">QMap</a>&lt;<a href="qstring.html">QString</a>, <a href="qvariant.html">QVariant</a>&gt;.</p>
<!-- @@@QVariantMap -->
<!-- $$$qvariant_cast[overload1]$$$qvariant_castconstQVariant& -->
<h3 class="fn" id="qvariant_cast"><a name="qvariant_cast"></a><span class="type">T</span> <span class="name">qvariant_cast</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>value</i>)</h3>
<p>Returns the given <i>value</i> converted to the template type <code>T</code>.</p>
<p>This function is equivalent to <a href="qvariant.html#value">QVariant::value</a>().</p>
<p><b>See also </b><a href="qvariant.html#value">QVariant::value</a>().</p>
<!-- @@@qvariant_cast -->
<!-- $$$operator!=$$$operator!=constQVariant&constQVariant& -->
<h3 class="fn" id="operator-not-eq-1"><a name="operator-not-eq-1"></a><span class="type">bool</span> <span class="name">operator!=</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v2</i>)</h3>
<p>Returns <code>false</code> if <i>v1</i> and <i>v2</i> are equal; otherwise returns <code>true</code>.</p>
<p><b>Warning:</b> To make this function work with a custom type registered with <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), its comparison operator must be registered using <a href="qmetatype.html#registerComparators">QMetaType::registerComparators</a>().</p>
<!-- @@@operator!= -->
<!-- $$$operator==$$$operator==constQVariant&constQVariant& -->
<h3 class="fn" id="operator-eq-eq-1"><a name="operator-eq-eq-1"></a><span class="type">bool</span> <span class="name">operator==</span>(const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvariant.html#QVariant">QVariant</a></span> &amp;<i>v2</i>)</h3>
<p>Returns <code>true</code> if <i>v1</i> and <i>v2</i> are equal; otherwise returns <code>false</code>.</p>
<p>If <i>v1</i> and <i>v2</i> have the same <a href="qvariant.html#type">type()</a>, the type's equality operator is used for comparison. If not, it is attempted to <a href="qvariant.html#convert">convert()</a> <i>v2</i> to the same type as <i>v1</i>. See <a href="qvariant.html#canConvert-1">canConvert()</a> for a list of possible conversions.</p>
<p>The result of the function is not affected by the result of <a href="qvariant.html#isNull">QVariant::isNull</a>, which means that two values can be equal even if one of them is null and another is not.</p>
<p><b>Warning:</b> To make this function work with a custom type registered with <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), its comparison operator must be registered using <a href="qmetatype.html#registerComparators">QMetaType::registerComparators</a>().</p>
<!-- @@@operator== -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2018 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>