QT with Visual Studio 2008 and 2010 (updated for Qt 4.7.x and 4.8.x)

These directions will allow Qt4 to be installed and used by Visual Studio 2008 or 2010.

1. Pre-build Setup

  1. Apply service pack 1 to Visual Studio if it has not already been done.
  2. Download the latest version of QT’s source code (not the minGW binaries) from here.
  3. Extract the source into C:\Source\Qt\4.x.x-32bit or a similar path. This path will be referred to as QTDIR for the remainder of this document. Qt compilation will fail if there are spaces in the path or if the path is changed after the compilation process has completed.
  4. Create the environment variables:
    1. Go to “Control Panel” → “System” → “Advanced” → “Environment Variables”
    2. Within the user variables section, click New to bring up the New User Variable dialog. User variables should be used (instead of system-wide environment variables) because multiple versions and configurations of Qt can be compiled and available on one computer simultaneously. By using User Variables, changes to one user’s variables will not affect other users of the computer.
    3. Fill in the dialog. Fill in the name field with “QTDIR” and the value field with the path to the Qt source code.
    4. Click ok.
    5. Create a user environment variable PATH (or edit it if it already exists). Set the value to %QTDIR%\bin if PATH didn’t already exist and prepend %QTDIR%\bin; (note the semicolon at the end) if it did.
    6. Click ok twice.

In order to install QT 4.6, it is best to enable the Dx86 environment from within the Visual Studio Command Prompt (this is not necessary for Qt 4.7 or 4.8), but does not hurt). In order to complete these steps, the DirectX SDK must be installed. The latest DirectX SDK, as of this writing, is the June 2010 build (download). You can check for a newer version here.

    1. Enabling the Dx86 environment:

    1. Once the DirectX SDK is installed, navigate to: “Start” → “All Programs” → “Microsoft DirectX SDK (June 2010)” and right click on “DirectX SDK Command Prompt”.
    2. Click on Properties
    3. In the target field of the DirectX SDK Command Prompt Properties window, copy the string contained within the target field. If you are using the June 2010 build, the string reads as follows: "C:\Program Files\Microsoft DirectX SDK (June 2010)\Utilities\Bin\dx_setenv.cmd" or for 64-bit systems "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Utilities\Bin\dx_setenv.cmd"
      • Note: the string will be in two sets of quotation marks. ONLY copy the string and one set of quotation marks. What you have copied should resemble the string shown in the step above.
    4. Open the Visual Studio Command Prompt by clicking: “Start” → “All Programs” → “Microsoft Visual Studio 2008″ → “Visual Studio Tools” → “Visual Studio 2008 Command Prompt”.
    5. Paste the string you copied in step 3 into the Command prompt. You should receive the following message: “Dx86 target environment is now enabled. Dx86 host environment is now enabled.”

2. Build Qt

  1. Open the Visual Studio Command Prompt by clicking: “Start” → “All Programs” → “Microsoft Visual Studio 2008″ → “Visual Studio Tools” → “Visual Studio 2008 Command Prompt”.
  2. Navigate to the Qt directory: cd %QTDIR%
  3. Configure Qt (Visual Studio 2008):
    configure -opensource -confirm-license -debug-and-release -platform win32-msvc2008 -mp -ltcg

    • help – Print a list of configuration options.
    • opensource – Compile and link the Open-Source Edition of Qt.
    • confirm-license – Accepts the supplied license by default (in this case, opensource).
    • debug-and-release – Enable generation of both debug and release mode executables.
    • platform win32-msvc2008 – Specifies the desired compiler.
    • mp – Use multiple processors for compiling with MSVC (-MP).
    • ltcg – Use Link Time Code Generation. (Release builds only). This can increase performance by 10%-15%. However, the size of the library will be larger. ltcg does not work with Qt 4.8.0, but it does work for version 4.8.1+ (See the bug report), but there is a two-step work-around. First, delete the files bin/syncqt and bin/syncqt.bat. Second, add the following lines to the file src\3rdparty\webkit\Source\WebCore\WebCore.pro immediately after the line DEFINES += QT_MAKEDLL.
        QMAKE_LFLAGS_LTCG = 
        QMAKE_CXXFLAGS_LTCG = 
        QMAKE_CFLAGS_LTCG =

  4. Alternatively, for Visual Studio 2010,Configure Qt: configure -opensource -confirm-license -debug-and-release -platform win32-msvc2010 -mp -ltcg
    A full list of parameters can be found at Configuration Options for Qt.
  5. Choose which license you would like to use and enter y when prompted. The configuration process will take a few minutes.
  6. Build Qt. This will take a long time.
    nmake
  7. Delete all intermediate files produced in the build process. These file are no longer needed.
    nmake clean
  8. Note: You can setup these commands to run in succession by entering them as one command with each part separated by && (works for Windows 2000 and above).
    configure -opensource -confirm-license -debug-and-release -platform win32-msvc2010 -ltcg -mp && nmake && nmake clean

3.  Optional Visual Studio Improvements

3.1 Improve Debugger Support for Qt datatypes

Add the following lines to the file /Common7/Packages/Debugger/autoexp.dat just before the line “[Visualizer]“. Note: If you are on the Windows Vista or Windows 7 platform, you must open the text editor in “Run as Administrator” mode.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
; Qt Integration
QObject =classname=<staticMetaObject.d.stringdata,s> superclassname=<staticMetaObject.d.superdata->d.stringdata,s>
QList<*>=size=<d->end,i>
QLinkedList<*>=size=<d->end,i>
QString=<d->data,su> size=<d->size,u>
QByteArray=<d->data,s> size=<d->size,u>
QUrl =<d->encodedOriginal.d->data,s>
QUrlInfo =<d->name.d->data,su>
QPoint =x=<xp> y=<yp>
QPointF =x=<xp> y=<yp>
QRect =x1=<x1> y1=<y1> x2=<x2> y2=<y2>
QRectF =x=<xp> y=<yp> w=<w> h=<h>
QSize =width=<wd> height=<ht>
QSizeF =width=<wd> height=<ht>
QMap<*> =size=<d->size>
QVector<*> =size=<d->size>
QHash<*> =size=<d->size>
QVarLengthArray<*> =size=<s> data=<ptr>
QFont =family=<d->request.family.d->data,su> size=<d->request.pointSize, f>
QDomNode =name=<impl->name.d->data,su> value=<impl->value.d->data,su>

Add the following just after the [Visualizer] tag. This has been taken directly from the Qt Visual Studio Add-in, which is not required.

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
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
;QT_DEBUG_START (Qt Visual Studio Add-in v1.1.10)
; Nokia Qt 4.x visualizers -----------------------------------------[ start ]--
;------------------------------------------------------------------------------
; Feel free to modify these visualizers to suit yours needs! But please let us
; know about the changes you make, so we continuously improve the visualizers.
 
QString|*::QString{
    preview         ([$e.d->data,su])
    stringview      ([$e.d->data,sub])
    children
    (
        #(
            d: $c.d,
            [size]: $c.d->size,
            [referenced]: $c.d->ref._q_value
        )
    )
}
 
QByteArray|*::QByteArray{
    preview         ([$e.d->data,s])
    stringview      ([$e.d->data,sb])
    children
    (
        #(
            d: $c.d,
            [size]: $c.d->size,
            [referenced]: $c.d->ref._q_value
        )
    )
}
 
QFileInfo|*::QFileInfo{
    preview
    (
        #(
            "private=", $c.d_ptr
        )
    )
}
 
QUrl|*::QUrl{
    preview
    (
        #if ($e.d.stateFlags == 0) (
            $e.d
        ) #else (
            #( $e.d->scheme, $e.d->host, $e.d->path )
        )
    )
    children
    (
        #(
            scheme: $c.d->scheme,
            host: $c.d->host,
            path: $c.d->path,
            username: $c.d->userName,
            password: $c.d->password,
            encodedOriginal: $c.d->encodedOriginal,
            query: $c.d->query,
            fragment: $c.d->fragment
        )
    )
}
 
QTime|*::QTime{
    preview
    (
        #(
            "hour=", [$e.mds / 3600000, d],
            ", minute=", [($e.mds % 3600000) / 60000, d],
            ", second=", [($e.mds / 1000) % 60, d],
            ", millisecond=", [$e.mds % 1000, d]
        )
    )
    children
    (
        #(
            [hour]: [$e.mds / 3600000, d],
            [minute]: [($e.mds % 3600000) / 60000, d],
            [second]: [($e.mds / 1000) % 60, d],
            [millisecond]: [$e.mds % 1000, d]
        )
    )
}
 
QVariant{
    preview
    (
        #if ($e.d.type == 1) (
            #("bool = ", [$e.d.data.b])
        ) #elif ($e.d.type == 2) (
            #("int = ", [$e.d.data.i])
        ) #elif ($e.d.type == 3) (
            #("usigned int = ", [$e.d.data.u])
        ) #elif ($e.d.type == 4) (
            #("long long = ", [$e.d.data.ll])
        ) #elif ($e.d.type == 5) (
            #("unsigned long long = ", [$e.d.data.ull])
        ) #elif ($e.d.type == 6) (
            #("double = ", [$e.d.data.d])
        ) #elif ($e.d.type == 7) (
            #("char = ", [$e.d.data.c])
        ) #elif ($e.d.type == 8) (
            #("QMap = ", [(QMap) $e.d.data.ptr])
        ) #elif ($e.d.type == 10) (
            #("QString = ", [(QString) $e.d.data.ptr])
        ) #elif ($e.d.type == 11) (
            #("QStringList = ", [(QStringList) $e.d.data.ptr])
        ) #elif ($e.d.type == 17) (
            #("QUrl = ", [(QUrl) $e.d.data.ptr])
        ) #else (
            #("type = ", [$e.d.type])
        )
    )
    children
    (
        #if ($e.d.type == 1) (
            $c.d.data.b
        ) #elif ($e.d.type == 2) (
            $c.d.data.i
        ) #elif ($e.d.type == 3) (
            $c.d.data.u
        ) #elif ($e.d.type == 4) (
            $c.d.data.ll
        ) #elif ($e.d.type == 5) (
            $c.d.data.ull
        ) #elif ($e.d.type == 6) (
            $c.d.data.d
        ) #elif ($e.d.type == 7) (
            $c.d.data.c
        ) #elif ($e.d.type == 8) (
        ) #elif ($e.d.type == 10) (
            #(
                [size]: ((QString) $c.d.data.ptr).d->size
            )
        ) #elif ($e.d.type == 11) (
            #if ((((QStringList) $e.d.data.ptr).d->end - ((QStringList) $e.d.data.ptr).d->begin) <= 10) (
               #array
               (
                    expr: (QString)((((QStringList) $e.d.data.ptr).d->array + ((QStringList) $e.d.data.ptr).d->begin)[$i]),
                    size: ((QStringList) $e.d.data.ptr).d->end-((QStringList) $e.d.data.ptr).d->begin
                )
            ) #else (
                #array
                (
                    expr: (QString)((((QStringList) $e.d.data.ptr).d->array + ((QStringList) $e.d.data.ptr).d->begin)[$i]),
                    size: 10
                )
            )
        ) #elif ($e.d.type == 17) (
            #(
                scheme: ((QUrl) $e.d.data.ptr).d->scheme,
                host: ((QUrl) $e.d.data.ptr).d->host,
                path: ((QUrl) $e.d.data.ptr).d->path,
                username: ((QUrl) $e.d.data.ptr).d->userName,
                password: ((QUrl) $e.d.data.ptr).d->password,
                encodedOriginal: ((QUrl) $e.d.data.ptr).d->encodedOriginal,
                query: ((QUrl) $e.d.data.ptr).d->query,
                fragment: ((QUrl) $e.d.data.ptr).d->fragment
            )
        ) #else (
            #("type = ", [$e.d.type])
        )
    )
}
 
*::QVariant{
    preview
    (
        #if ($e.d.type == 1) (
            #("bool = ", [$e.d.data.b])
        ) #elif ($e.d.type == 2) (
            #("int = ", [$e.d.data.i])
        ) #elif ($e.d.type == 3) (
            #("usigned int = ", [$e.d.data.u])
        ) #elif ($e.d.type == 4) (
            #("long long = ", [$e.d.data.ll])
        ) #elif ($e.d.type == 5) (
            #("unsigned long long = ", [$e.d.data.ull])
        ) #elif ($e.d.type == 6) (
            #("double = ", [$e.d.data.d])
        ) #elif ($e.d.type == 7) (
            #("char = ", [$e.d.data.c])
        ) #elif ($e.d.type == 8) (
            #("QMap = ", [($T1::QMap) $e.d.data.ptr])
        ) #elif ($e.d.type == 10) (
            #("QString = ", [($T1::QString) $e.d.data.ptr])
        ) #elif ($e.d.type == 11) (
            #("QStringList = ", [($T1::QStringList) $e.d.data.ptr])
        ) #elif ($e.d.type == 17) (
            #("QUrl = ", [($T1::QUrl) $e.d.data.ptr])
        ) #else (
            #("type = ", [$e.d.type])
        )
    )
    children
    (
        #if ($e.d.type == 1) (
            $c.d.data.b
        ) #elif ($e.d.type == 2) (
            $c.d.data.i
        ) #elif ($e.d.type == 3) (
            $c.d.data.u
        ) #elif ($e.d.type == 4) (
            $c.d.data.ll
        ) #elif ($e.d.type == 5) (
            $c.d.data.ull
        ) #elif ($e.d.type == 6) (
            $c.d.data.d
        ) #elif ($e.d.type == 7) (
            $c.d.data.c
        ) #elif ($e.d.type == 8) (
        ) #elif ($e.d.type == 10) (
            #(
                [size]: (($T1::QString) $c.d.data.ptr).d->size
            )
        ) #elif ($e.d.type == 11) (
            #if (((($T1::QStringList) $e.d.data.ptr).d->end - (($T1::QStringList) $e.d.data.ptr).d->begin) <= 10) (
               #array
               (
                    expr: ($T1::QString)(((($T1::QStringList) $e.d.data.ptr).d->array + (($T1::QStringList) $e.d.data.ptr).d->begin)[$i]),
                    size: (($T1::QStringList) $e.d.data.ptr).d->end-(($T1::QStringList) $e.d.data.ptr).d->begin
                )
            ) #else (
                #array
                (
                    expr: ($T1::QString)(((($T1::QStringList) $e.d.data.ptr).d->array + (($T1::QStringList) $e.d.data.ptr).d->begin)[$i]),
                    size: 10
                )
            )
        ) #elif ($e.d.type == 17) (
            #(
                scheme: (($T1::QUrl) $e.d.data.ptr).d->scheme,
                host: (($T1::QUrl) $e.d.data.ptr).d->host,
                path: (($T1::QUrl) $e.d.data.ptr).d->path,
                username: (($T1::QUrl) $e.d.data.ptr).d->userName,
                password: (($T1::QUrl) $e.d.data.ptr).d->password,
                encodedOriginal: (($T1::QUrl) $e.d.data.ptr).d->encodedOriginal,
                query: (($T1::QUrl) $e.d.data.ptr).d->query,
                fragment: (($T1::QUrl) $e.d.data.ptr).d->fragment
            )
        ) #else (
            #("type = ", [$e.d.type])
        )
    )
}
 
;------------------------------------------------------------------------------
; QStringList
;------------------------------------------------------------------------------
QStringList{
    preview
    (
        #if (($c.d->end - $c.d->begin) <= 10) (
            #(
                "[", $c.d->end - $c.d->begin, "](",
                #array
                (
                    expr: (QString)(($c.d->array + $c.d->begin)[$i]),
                    size: $c.d->end-$c.d->begin
                ), ")"
            )
        ) #else (
            #(
                "[", $c.d->end - $c.d->begin, "](",
                #array
                (
                    expr: (QString)(($c.d->array + $c.d->begin)[$i]),
                    size: 10
                ), ", ...)"
            )
        )
    )
}
 
*::QStringList{
    preview
    (
        #if (($c.d->end - $c.d->begin) <= 10) (
            #(
                "[", $c.d->end - $c.d->begin, "](",
                #array
                (
                    expr: ($T1::QString)(($c.d->array + $c.d->begin)[$i]),
                    size: $c.d->end-$c.d->begin
                ), ")"
            )
        ) #else (
            #(
                "[", $c.d->end - $c.d->begin, "](",
                #array
                (
                    expr: ($T1::QString)(($c.d->array + $c.d->begin)[$i]),
                    size: 10
                ), ", ...)"
            )
        )
    )
}
 
;------------------------------------------------------------------------------
; QList, QQueue
;------------------------------------------------------------------------------
QList<*>|QQueue<*>{
    preview
    (
        #if (int(sizeof($T1)) <= int(sizeof(void*))) (
            #if (($c.d->end - $c.d->begin) <= 10) (
                #(
                    "[", $c.d->end - $c.d->begin, "](",
                    #array
                    (
                        expr: ($T1)(($c.d->array + $c.d->begin)[$i]),
                        size: $c.d->end-$c.d->begin
                    ), ")"
                )
            ) #else (
                #(
                    "[", $c.d->end - $c.d->begin, "](",
                    #array
                    (
                        expr: ($T1)(($c.d->array + $c.d->begin)[$i]),
                        size: 10
                    ), ", ...)"
                )
            )
        ) #else (
            #if (($c.d->end - $c.d->begin) <= 10) (
                #(
                    "[", $c.d->end - $c.d->begin, "](",
                    #array
                    (
                        expr: *($T1*)(($c.d->array + $c.d->begin)[$i]),
                        size: $c.d->end-$c.d->begin
                    ), ")"
                )
            ) #else (
                #(
                    "[", $c.d->end - $c.d->begin, "](",
                    #array
                    (
                        expr: *($T1*)(($c.d->array + $c.d->begin)[$i]),
                        size: 10
                    ), ", ...)"
                )
            )
        )
    )
    children
    (
        #if (int(sizeof($T1)) <= int(sizeof(void*))) (
            #array (
                expr: ($T1)(($c.d->array + $c.d->begin)[$i]),
                size: $c.d->end - $c.d->begin
            )
        ) #else (
            #array (
                expr: *($T1*)(($c.d->array + $c.d->begin)[$i]),
                size: $c.d->end - $c.d->begin
            )
        )
    )
}
 
*::QList<*>|*::QQueue<*>{
    preview
    (
        #if (int(sizeof($T2)) <= int(sizeof(void*))) (
            #if (($c.d->end - $c.d->begin) <= 10) (
                #(
                    "[", $c.d->end - $c.d->begin, "](",
                    #array
                    (
                        expr: ($T2)(($c.d->array + $c.d->begin)[$i]),
                        size: $c.d->end-$c.d->begin
                    ), ")"
                )
            ) #else (
                #(
                    "[", $c.d->end - $c.d->begin, "](",
                    #array
                    (
                        expr: ($T2)(($c.d->array + $c.d->begin)[$i]),
                        size: 10
                    ), ", ...)"
                )
            )
        ) #else (
            #if (($c.d->end - $c.d->begin) <= 10) (
                #(
                    "[", $c.d->end - $c.d->begin, "](",
                    #array
                    (
                        expr: *($T2*)(($c.d->array + $c.d->begin)[$i]),
                        size: $c.d->end-$c.d->begin
                    ), ")"
                )
            ) #else (
                #(
                    "[", $c.d->end - $c.d->begin, "](",
                    #array
                    (
                        expr: *($T2*)(($c.d->array + $c.d->begin)[$i]),
                        size: 10
                    ), ", ...)"
                )
            )
        )
    )
    children
    (
        #if (int(sizeof($T2)) <= int(sizeof(void*))) (
            #array (
                expr: ($T2)(($c.d->array + $c.d->begin)[$i]),
                size: $c.d->end - $c.d->begin
            )
        ) #else (
            #array (
                expr: *($T2*)(($c.d->array + $c.d->begin)[$i]),
                size: $c.d->end - $c.d->begin
            )
        )
    )
}
 
;------------------------------------------------------------------------------
; QList::iterator, QQueue::iterator
;------------------------------------------------------------------------------
QList<*>::iterator|QList<*>::const_iterator|QQueue<*>::iterator|QQueue<*>::const_iterator{
    preview
    (
        #(
            ($T1*)$c.ptr
        )
    )
    children
    (
        #(
            ptr: ($T1)$c.ptr
        )
    )
}
 
*::QList<*>::iterator|*::QList<*>::const_iterator|*::QQueue<*>::iterator|*::QQueue<*>::const_iterator{
    preview
    (
        #(
            ($T2)$c.i->v
        )
    )
    children
    (
        #(
            ptr: ($T2)$c.i->v
        )
    )
}
 
;------------------------------------------------------------------------------
; QListIterator
;------------------------------------------------------------------------------
QListIterator<*>|QMutableListIterator<*>{
    preview
    (
        #(
            *($T1*)($c.i.i->v)
        )
    )
    children
    (
        #(
            Value: *($T1*)($c.i.i->v)
        )
    )
}
 
*::QListIterator<*>|*::QMutableListIterator<*>{
    preview
    (
        #(
            *($T2*)($c.i.i->v)
        )
    )
    children
    (
        #(
            Value: *($T2*)($c.i.i->v)
        )
    )
}
 
;------------------------------------------------------------------------------
; QLinkedList
;------------------------------------------------------------------------------
QLinkedList<*>{
    preview
    (
        #if ($e.d->size >= 10) (
            #(
                "[", $e.d->size, "](",
                #list
                (
                    head: $c.d->n,
                    size: 10,
                    next: n
                ) : ( (*(QLinkedListNode<$T1>*)&$e).t ), ", ...)"
            )
        ) #else (
            #(
                "[", $e.d->size, "](",
                #list
                (
                    head: $c.d->n,
                    size: $c.d->size,
                    next: n
                ) : ( (*(QLinkedListNode<$T1>*)&$e).t ), ")"
            )
        )
    )
    children
    (
        #(
            #list
            (
                head: $c.d->n,
                size: $c.d->size,
                next: n
            ) : (*(QLinkedListNode<$T1>*)&$e).t
        )
    )
}
 
*::QLinkedList<*>{
    preview
    (
        #if ($e.d->size >= 10) (
            #(
                "[", $e.d->size, "](",
                #list
                (
                    head: $c.d->n,
                    size: 10,
                    next: n
                ) : ( (*($T1::QLinkedListNode<$T2>*)&$e).t ), ", ...)"
            )
        ) #else (
            #(
                "[", $e.d->size, "](",
                #list
                (
                    head: $c.d->n,
                    size: $c.d->size,
                    next: n
                ) : ( (*($T1::QLinkedListNode<$T2>*)&$e).t ), ")"
            )
        )
    )
    children
    (
        #(
            #list
            (
                head: $c.d->n,
                size: $c.d->size,
                next: n
            ) : (*($T1::QLinkedListNode<$T2>*)&$e).t
        )
    )
}
 
;------------------------------------------------------------------------------
; QLinkedList::iterator
;------------------------------------------------------------------------------
QLinkedList<*>::iterator|*::QLinkedList<*>::iterator|QLinkedList<*>::const_iterator|*::QLinkedList<*>::const_iterator{
    preview
    (
        #(
            $e.i->t
        )
    )
    children
    (
        #(
            ptr: $e.i->t
        )
    )
}
 
QLinkedListIterator<*>|*::QLinkedListIterator<*>{
    preview
    (
        #(
            $c.i
        )
    )
    children
    (
        #(
            value: $c.i
        )
    )
}
 
;------------------------------------------------------------------------------
; QVector, QStack
;
; By default, this visualizer supports only Qt 4.6.x. If you're going to use
; Qt 4.5.x code, then you may want to replace all expr lines with this:
;    expr: (((size_t)($c.d) + (size_t)(sizeof(QVectorData)) ))[$i],
;
; This will allow this visualizer to display Qt 4.5.x and Qt 4.6.x QVector
; objects. But be aware of some limitations. For example enum types can't be
; displayed properly this way.
;
; Qt 4.5.x:
;     QVector::d is QVectorTypedData<T>
;     QVector::p is QVectorData
;     expr: $c.d->array[$i]
;
; Qt 4.6.x:
;     QVector::d is QVectorData
;     QVector::p is QVectorTypedData<T>
;     expr: $c.p->array[$i]
;
;------------------------------------------------------------------------------
QVector<*>|*::QVector<*>|QStack<*>|*::QStack<*>{
    preview
    (
        #if ($c.d->size <= 10) (
            #(
                "[", $c.d->size, "](",
                #array
                (
                    expr: $c.p->array[$i],
                    size: $c.d->size
                ), ")"
            )
        ) #else (
            #(
                "[", $c.d->size, "](",
                #array
                (
                    expr: $c.p->array[$i],
                    size: 10
                ), ", ...)"
            )
        )
    )
    children
    (
        #array
        (
            expr: $c.p->array[$i],
            size: $c.d->size
        )
    )
}
 
;------------------------------------------------------------------------------
; QMap
;------------------------------------------------------------------------------
QMapNode<*,*>{
    preview
    (
        #(
            "(",
            $e.key,
            "; ",
            $e.value,
            ")"
        )
    )
 
    children
    (
        #(
            key: $e.key,
            value: $e.value
        )
    )
}
 
QMap<*>{
    children
    (
        #(
            raw data: [$c,!],
            #tree
            (
                head : $c.d->forward[0],
                skip : $c.d,
                size : $c.d->size,
                left : backward,
                right : forward
            ) : ( (QMapNode<$T1>*)((char*)&$e - (sizeof(QMapPayloadNode<$T1>) - sizeof(QMapData::Node*))) )
        )
    )
 
    preview
    (
        #(
            "[",
            $e.d->size,
            "](",
                #tree
                (
                    head : $c.d->forward[0],
                    size : $c.d->size,
                    left : backward,
                    right : forward
                ) : $e,
            ")"
        )
    )
}
 
;------------------------------------------------------------------------------
; QHash
;------------------------------------------------------------------------------
QHash<*>{
    preview
    (
        #(
            "[", $e.d->size, "] (...)"
        )
    )
    children
    (
        #if ($e.d->size <= 255) (
            #(
                #array (
                    expr: (QHashNode<$T1>*)$c.d->buckets[$i],
                    size: $c.d->numBuckets
                ) : #list (
                    head: $e,
                    next: next
                ) : #switch ($e.next != 0) #case 1 (
                    $e
                )
            )
        ) #else (
            #(
                #array (
                    expr: (QHashNode<$T1>*)$c.d->buckets[$i],
                    size: 255
                ) : #list (
                    head: $e,
                    next: next
                ) : #switch ($e.next != 0) #case 1 (
                    $e
                )
            )
        )
    )
}
 
*::QHash<*>{
    preview
    (
        #(
             "[", $e.d->size, "] (...)"
        )
    )
    children
    (
        #if ($e.d->size <= 255) (
            #(
                #array (
                    expr: ($T1::QHashNode<$T2> *)$c.d->buckets[$i],
                    size: $c.d->numBuckets
                ) : #list (
                    head: $e,
                    next: next
                ) : #switch ($e.next != 0) #case 1 (
                    $e
                )
            )
        ) #else (
            #(
                #array (
                    expr: ($T1::QHashNode<$T2> *)$c.d->buckets[$i],
                    size: 255
                ) : #list (
                    head: $e,
                    next: next
                ) : #switch ($e.next != 0) #case 1 (
                    $e
                )
            )
        )
    )
}
 
;------------------------------------------------------------------------------
; QMultiHash
;------------------------------------------------------------------------------
QMultiHash<*>{
    preview
    (
        (*(QHash<$T1>*)(&$c))
    )
}
 
*::QMultiHash<*>{
    preview
    (
        (*($T1::QHash<$T2>*)(&$c))
    )
}
 
;------------------------------------------------------------------------------
; QHash::iterator
;------------------------------------------------------------------------------
QHash<*>::iterator{
    preview
    (
        #(
            "(", ((QHashNode<$T1>*)($c.i))->key, ", ", ((QHashNode<$T1>*)($c.i))->value, ")"
        )
    )
    children
    (
        #(
            key: ((QHashNode<$T1>*)($c.i))->key,
            value: ((QHashNode<$T1>*)($c.i))->value
        )
    )
}
 
*::QHash<*>::iterator{
    preview
    (
        #(
            "(", (($T1::QHashNode<$T2>*)($c.i))->key, ", ", (($T1::QHashNode<$T2>*)($c.i))->key, ")"
        )
    )
    children
    (
        #(
            key: (($T1::QHashNode<$T2>*)($c.i))->key,
            value: (($T1::QHashNode<$T2>*)($c.i))->value
        )
    )
}
 
;------------------------------------------------------------------------------
; QHashIterator
;------------------------------------------------------------------------------
QHashIterator<*>{
    preview
    (
        #(
            "(", ((QHashNode<$T1>*)((($c).i).i))->key, ", ", ((QHashNode<$T1>*)((($c).i).i))->key, ")"
        )
    )
    children
    (
        #(
            key: ((QHashNode<$T1>*)((($c).i).i))->key,
            value: ((QHashNode<$T1>*)((($c).i).i))->value
        )
    )
}
 
*::QHashIterator<*>{
    preview
    (
        #(
            "(", (($T1::QHashNode<$T2>*)((($c).i).i))->key, ", ", (($T1::QHashNode<$T2>*)((($c).i).i))->key, ")"
        )
    )
    children
    (
        #(
            key: (($T1::QHashNode<$T2>*)((($c).i).i))->key,
            value: (($T1::QHashNode<$T2>*)((($c).i).i))->value
        )
    )
}
 
;------------------------------------------------------------------------------
; QHashNode
;------------------------------------------------------------------------------
QHashNode<*>|*::QHashNode<*>{
    preview
    (
        #(
            "(key = ", $c.key,"; value = ", $c.value, ")"
        )
    )
    children
    (
        #(
            key: $c.key,
            value: $c.value
        )
    )
}
 
;------------------------------------------------------------------------------
; QSet
;------------------------------------------------------------------------------
QSet<*>{
    preview
    (
        #(
             "[", $e.q_hash.d->size, "] (...)"
        )
    )
    children
    (
        #if ($e.q_hash.d->size <= 255) (
            #(
                #array (
                    expr: (QHashNode<$T1,QHashDummyValue> *)$c.q_hash.d->buckets[$i],
                    size: $c.q_hash.d->numBuckets
                ) : #list (
                    head: $e,
                    next: next
                ) : #switch ($e.next != 0) #case 1 (
                    $e.key
                )
            )
        ) #else (
            #(
                #array (
                    expr: (QHashNode<$T1,QHashDummyValue> *)$c.q_hash.d->buckets[$i],
                    size: 255
                ) : #list (
                    head: $e,
                    next: next
                ) : #switch ($e.next != 0) #case 1 (
                    $e.key
                )
            )
        )
    )
}
 
*::QSet<*>{
    preview
    (
        #(
             "[", $e.q_hash.d->size, "] (...)"
        )
    )
    children
    (
        #if ($e.q_hash.d->size <= 255) (
            #(
                #array (
                    expr: ($T1::QHashNode<$T2,QHashDummyValue> *)$c.q_hash.d->buckets[$i],
                    size: $c.q_hash.d->numBuckets
                ) : #list (
                    head: $e,
                    next: next
                ) : #switch ($e.next != 0) #case 1 (
                    $e.key
                )
            )
        ) #else (
            #(
                #array (
                    expr: ($T1::QHashNode<$T2,QHashDummyValue> *)$c.q_hash.d->buckets[$i],
                    size: 255
                ) : #list (
                    head: $e,
                    next: next
                ) : #switch ($e.next != 0) #case 1 (
                    $e.key
                )
            )
        )
    )
}
 
;------------------------------------------------------------------------------
; QPalette
;------------------------------------------------------------------------------
QPalette{
    children
    (
        #(
            WindowText_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 0)->d,
            Button_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 1)->d,
            Light_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 2)->d,
            Midlight_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 3)->d,
            Dark_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 4)->d,
            Mid_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 5)->d,
            Text_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 6)->d,
            BrightText_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 7)->d,
            ButtonText_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 8)->d,
            Base_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 9)->d,
            Window_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+10)->d,
            Shadow_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+11)->d,
            Highlight_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+12)->d,
            HighlightedText_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+13)->d,
            Link_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+14)->d,
            LinkVisited_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+15)->d,
            AlternateBase_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+16)->d,
            NoRole_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+17)->d,
            ToolTipBase_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+18)->d,
            ToolTipText_active:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+19)->d,
 
            WindowText_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 0)->d,
            Button_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 1)->d,
            Light_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 2)->d,
            Midlight_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 3)->d,
            Dark_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 4)->d,
            Mid_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 5)->d,
            Text_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 6)->d,
            BrightText_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 7)->d,
            ButtonText_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 8)->d,
            Base_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 9)->d,
            Window_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+10)->d,
            Shadow_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+11)->d,
            Highlight_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+12)->d,
            HighlightedText_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+13)->d,
            Link_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+14)->d,
            LinkVisited_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+15)->d,
            AlternateBase_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+16)->d,
            NoRole_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+17)->d,
            ToolTipBase_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+18)->d,
            ToolTipText_disabled:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+19)->d,
 
            WindowText_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 0)->d,
            Button_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 1)->d,
            Light_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 2)->d,
            Midlight_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 3)->d,
            Dark_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 4)->d,
            Mid_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 5)->d,
            Text_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 6)->d,
            BrightText_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 7)->d,
            ButtonText_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 8)->d,
            Base_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 9)->d,
            Window_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+10)->d,
            Shadow_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+11)->d,
            Highlight_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+12)->d,
            HighlightedText_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+13)->d,
            Link_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+14)->d,
            LinkVisited_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+15)->d,
            AlternateBase_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+16)->d,
            NoRole_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+17)->d,
            ToolTipBase_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+18)->d,
            ToolTipText_inactive:
                ((QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+19)->d
        )
    )
}
 
*::QPalette{
    children
    (
        #(
            WindowText_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 0)->d,
            Button_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 1)->d,
            Light_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 2)->d,
            Midlight_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 3)->d,
            Dark_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 4)->d,
            Mid_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 5)->d,
            Text_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 6)->d,
            BrightText_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 7)->d,
            ButtonText_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 8)->d,
            Base_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+ 9)->d,
            Window_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+10)->d,
            Shadow_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+11)->d,
            Highlight_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+12)->d,
            HighlightedText_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+13)->d,
            Link_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+14)->d,
            LinkVisited_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+15)->d,
            AlternateBase_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+16)->d,
            NoRole_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+17)->d,
            ToolTipBase_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+18)->d,
            ToolTipText_active:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+19)->d,
 
            WindowText_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 0)->d,
            Button_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 1)->d,
            Light_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 2)->d,
            Midlight_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 3)->d,
            Dark_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 4)->d,
            Mid_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 5)->d,
            Text_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 6)->d,
            BrightText_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 7)->d,
            ButtonText_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 8)->d,
            Base_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+ 9)->d,
            Window_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+10)->d,
            Shadow_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+11)->d,
            Highlight_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+12)->d,
            HighlightedText_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+13)->d,
            Link_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+14)->d,
            LinkVisited_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+15)->d,
            AlternateBase_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+16)->d,
            NoRole_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+17)->d,
            ToolTipBase_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+18)->d,
            ToolTipText_disabled:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+20+19)->d,
 
            WindowText_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 0)->d,
            Button_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 1)->d,
            Light_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 2)->d,
            Midlight_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 3)->d,
            Dark_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 4)->d,
            Mid_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 5)->d,
            Text_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 6)->d,
            BrightText_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 7)->d,
            ButtonText_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 8)->d,
            Base_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+ 9)->d,
            Window_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+10)->d,
            Shadow_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+11)->d,
            Highlight_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+12)->d,
            HighlightedText_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+13)->d,
            Link_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+14)->d,
            LinkVisited_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+15)->d,
            AlternateBase_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+16)->d,
            NoRole_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+17)->d,
            ToolTipBase_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+18)->d,
            ToolTipText_inactive:
                (($T1::QBrush*)((char*)$c.d+sizeof(QAtomicInt))+40+19)->d
        )
    )
}
 
;------------------------------------------------------------------------------
; QBrush
;------------------------------------------------------------------------------
QBrush|*::QBrush{
    preview
    (
        #(
            "[", $c.d->style, "] (...)"
        )
    )
    children
    (
        #(
            style: $c.d->style,
            color: $c.d->color,
            transform: $c.d->transform
        )
    )
}
 
QBrushData|*::QBrushData{
    preview
    (
        #(
            "[", $c.style, "] (...)"
        )
    )
    children
    (
        #(
            style: $c.style,
            color: $c.color,
            transform: $c.transform
        )
    )
}
 
;------------------------------------------------------------------------------
; QColor
;------------------------------------------------------------------------------
QColor|*::QColor{
    preview
    (
        #(
            #if ($c.cspec == 1) (
                #(
                    "[", $c.cspec, "] [", "r = ", [$c.ct.argb.red,x],
                                          ", g = ", [$c.ct.argb.green,x],
                                          ", b = ", [$c.ct.argb.blue,x], "] (...)"
                )
            ) #elif ($c.cspec == 2) (
                #(
                    "[", $c.cspec, "] [", "h = ", [$c.ct.ahsv.hue,x],
                                          ", s = ", [$c.ct.ahsv.saturation,x],
                                          ", v = ", [$c.ct.ahsv.value,x], "] (...)"
                )
            ) #elif ($c.cspec == 3) (
                #(
                    "[", $c.cspec, "] [", "c = ", [$c.ct.acmyk.cyan,x],
                                          ", m = ", [$c.ct.acmyk.magenta,x],
                                          ", y = ", [$c.ct.acmyk.yellow,x],
                                          ", k = ", [$c.ct.acmyk.black,x], "] (...)"
                )
            ) #else (
                #(
                    "[Invalid]"
                )
            )
        )
    )
    children
    (
        #(
            #if ($c.cspec == 1) (
                #(
                    red: [$c.ct.argb.red,x],
                    green: [$c.ct.argb.green,x],
                    blue: [$c.ct.argb.blue,x],
                    alpha: [$c.ct.argb.alpha,x],
            pad: [$c.ct.argb.pad,x]
                )
            ) #elif ($c.cspec == 2) (
                #(
                    hue: [$c.ct.ahsv.hue,x],
                    saturation: [$c.ct.ahsv.saturation,x],
                    value: [$c.ct.ahsv.value,x],
                    alpha: [$c.ct.ahsv.alpha,x],
            pad: [$c.ct.ahsv.pad,x]                    
                )
            ) #elif ($c.cspec == 3) (
                #(
                    cyan: [$c.ct.acmyk.cyan,x],
                    magenta: [$c.ct.acmyk.magenta,x],
                    yellow: [$c.ct.acmyk.yellow,x],
                    black: [$c.ct.acmyk.black,x],
                    alpha: [$c.ct.acmyk.alpha,x]
                )
            )
        )
    )
}
 
;------------------------------------------------------------------------------
; QTransform
;------------------------------------------------------------------------------
QTransform|*::QTransform{
    preview
    (
        #(
            "[",[$c.affine._m11,g]," ",[$c.affine._m12,g]," ",[$c.m_13,g],"]", 
            "[",[$c.affine._m21,g]," ",[$c.affine._m22,g]," ",[$c.m_23,g],"]",
            "[",[$c.affine._dx,g]," ",[$c.affine._dy,g]," ",[$c.m_33,g],"]"
        )
    )
    children
    (
        #(
            translation_horizontal_m31_dx: [$c.affine._dx,g],
            translation_vertical_m32_dy: [$c.affine._dy,g],
            scaling_horizontal_m11: [$c.affine._m11,g],
            scaling_vertical_m22: [$c.affine._m22,g],
            projection_factor_m33: [$c.m_33,g],
            projection_horizontal_m13: [$c.m_13,g],
            projection_vertical_m23: [$c.m_23,g],
            shearing_horizontal_m21: [$c.affine._m21,g],
            shearing_vertical_m12: [$c.affine._m12,g],
            type: $c.m_type,
            dirty: (bool)$c.m_dirty
        )
    )
}
 
;------------------------------------------------------------------------------
; QMatrix
;------------------------------------------------------------------------------
QMatrix|*::QMatrix{
    preview
    (
        #(
            "[",[$c._m11,g]," ",[$c._m12,g],"]", 
            "[",[$c._m21,g]," ",[$c._m22,g],"]",
            "[",[$c._dx,g]," ",[$c._dy,g],"]"
        )
    )
    children
    (
        #(
            translation_horizontal_dx: [$c._dx,g],
            translation_vertical_dy: [$c._dy,g],
            scaling_horizontal_m11: [$c._m11,g],
            scaling_vertical_m22: [$c._m22,g],
            shearing_horizontal_m21: [$c._m21,g],
            shearing_vertical_m12: [$c._m12,g]
        )
    )
}
 
;------------------------------------------------------------------------------
; QPolygon
;------------------------------------------------------------------------------
QPolygon{
    preview
    (
        #(
             "[", ((QVector<QPoint>*)(&$c))->d->size, "] (...)"
        )
    )
    children
    (
        #(
            #array
            (
                expr: ((QPoint*)(((void*)$c.d) + sizeof(QVectorData)))[$i],
                size: ((QVector<QPoint>*)(&$c))->d->size
            )
        )
    )
}
*::QPolygon{
    preview
    (
        #(
             "[", (($T1::QVector<$T1::QPoint>*)(&$c))->d->size, "] (...)"
        )
    )
    children
    (
        #(
            #array
            (
                expr: (($T1::QPoint*)(((void*)$c.d) + sizeof(QVectorData)))[$i],
                size: (($T1::QVector<$T1::QPoint>*)(&$c))->d->size
            )
        )
    )
}
 
;------------------------------------------------------------------------------
; QPolygonF
;------------------------------------------------------------------------------
QPolygonF{
    preview
    (
        #(
             "[", ((QVector<QPointF>*)(&$c))->d->size, "] (...)"
        )
    )
    children
    (
        #(
            #array
            (
                expr: ((QVector<QPointF>*)(&$c))->p->array[$i],
                size: ((QVector<QPointF>*)(&$c))->d->size
            )
        )
    )
}
 
*::QPolygonF{
    preview
    (
        #(
             "[", (($T1::QVector<$T1::QPointF>*)(&$c))->d->size, "] (...)"
        )
    )
    children
    (
        #(
            #array
            (
                expr: (($T1::QVector<$T1::QPointF>*)(&$c))->p->array[$i],
                size: (($T1::QVector<$T1::QPointF>*)(&$c))->d->size
            )
        )
    )
}
 
;------------------------------------------------------------------------------
; Nokia Qt 4.x visualizers -------------------------------------------[ end ]--
;QT_DEBUG_END

3.2 IntelliSense

IntelliSense settings for Qt can be added to Visual Studio’s options for all projects or set at the project level. Setting the options at the project level allows the settings to be maintained across multiple Visual Studio installs. However, the settings will have to be set after each new project is created.

To setup IntelliSense for all projects on your Visual Studio install, add the following lines to the Visual Studio include file paths dialog.

Visual Studio 2008 and earlier (per installation):

  1. Go to Tools->Options->Projects and Solutions->VC++ Directories
  2. Change the Show directories to “Include Files”.

Visual Studio 2010 (per user):

  1. Go to View->Property Manager
  2. Fully expand the tree
  3. Multi-select all .user files
  4. Right click and select properties
$(QTDIR)\include
$(QTDIR)\include\Qt
$(QTDIR)\include\QtCore
$(QTDIR)\include\QtGui
$(QTDIR)\include\ActiveQt
$(QTDIR)\include\Qt3Support
$(QTDIR)\include\QtAssistant
$(QTDIR)\include\QtDBus
$(QTDIR)\include\QtDeclarative
$(QTDIR)\include\QtDesigner
$(QTDIR)\include\QtHelp
$(QTDIR)\include\QtMultimedia
$(QTDIR)\include\QtNetwork
$(QTDIR)\include\QtOpenGL
$(QTDIR)\include\QtOpenVG
$(QTDIR)\include\QtScript
$(QTDIR)\include\QtScriptTools
$(QTDIR)\include\QtSql
$(QTDIR)\include\QtSvg
$(QTDIR)\include\QtTest
$(QTDIR)\include\QtUiTools
$(QTDIR)\include\QtWebKit
$(QTDIR)\include\QtXml
$(QTDIR)\include\QtXmlPatterns
$(QTDIR)\mkspecs\win32-msvc2008
$(QTDIR)\mkspecs\win32-msvc2010

  • When working with Qt (and qmake), running the rebuild command is often required. This primarily becomes an issue when changes are made to the .pro file or when Q_OBJECT is added or removed from files.
  • In order to not pollute the global namespace, the above .pro file examples use the no_keywords configuration option. This option disables Qt specific macros. Instead of using the standard Qt macros, use the Q_X equivalents (replacing X with the name of the macro, i.e. Q_SLOTS).
  • In order to use V-Tune with release builds of QT applications, the following needs to be added to the .pro file.

QMAKE_CXXFLAGS += /Zi
QMAKE_LFLAGS += /fixed:no
QMAKE_LFLAGS += /DEBUG

4. Qt Project Creation with Visual Studio

4.1 Using QtWizard

Because generating Qt makefile projects within Visual Studio can be tedious, especially when developing large numbers of smaller applications, a Visual Studio wizard has been produced that automates parts of the process. The installer for the wizard can be located at http://www.sanfordfreedman.com/utilities/. The QtWizard integrates into Visual Studio and lets the user generate a Qt makefile project in the same manner as a standard Win32 or other inherently supported project type.

4.2 Manual Project Creation
  1. Ensure the environment variable %QTDIR% points to your installation of QT.
  2. Open Visual Studio and select File -> New ->Project.
  3. Select General and then Makefile Project.
  4. After providing a name and location for the new Makefile project, click Ok.
  5. Configure nmake. Makefiles require that nmake be properly configured for the new project. This can be accomplished in two locations, within the Makefile Project Wizard or within the project properties dialog after the project has been fully created. (TODO: Complete Intellisense section)
  6. Configuring nmake with the Makefile Project Wizard.

    1. Select Debug Configuration Settings.
    2. Fill in the following fields:
      Build Command Line:

       %QTDIR%\bin\qmake
          nmake debug

      Rebuild All Command Line:

       %QTDIR%\bin\qmake
          nmake debug-clean
          nmake debug

      Clean Command Line:

       %QTDIR%\bin\qmake
          nmake debug-clean

      Output:

      debug\[ApplicationName].exe
    3. Select Release Configuration Settings.
    4. Uncheck the Same as debug configuration box.
    5. Fill in the following fields:
      Build Command Line:

       %QTDIR%\bin\qmake
          nmake release

      Rebuild All Command Line:

       %QTDIR%\bin\qmake
          nmake release-clean
          nmake release

      Clean Command Line:

      %QTDIR%\bin\qmake
          nmake release-clean

      Output:

      release\[ApplicationName].exe
    6. Click Finish to complete the creation of the new Makefile project.

    Configuring nmake with Properties Pages dialog

    1. With the project open, right click on the name of the project within the Solution Explorer toolbar (generally on the left side of the IDE).
    2. Select Properties in the popup menu.
    3. Select NMake to access the nmake configuration section.
    4. Under Configuration, select Debug to edit the Debug Configuration properties.
    5. Fill in the four properties listed under General.
      Build Command Line:

      %QTDIR%\bin\qmake
          nmake debug

      Rebuild All Command Line:

      %QTDIR%\bin\qmake
          nmake debug-clean
          nmake debug

      Clean Command Line:

       %QTDIR%\bin\qmake
          nmake debug-clean

      Output:

      debug\[ApplicationName].exe
    6. Under configuration, select Release to edit the Release Configuration properties. If asked to save settings, select Yes.
    7. Fill in the four properties listed under General.
      Build Command Line:

      %QTDIR%\bin\qmake
          nmake release

      Rebuild All Command Line:

      %QTDIR%\bin\qmake
          nmake release-clean
          nmake release

      Clean Command Line:

      %QTDIR%\bin\qmake
          nmake release-clean

      Output:

      release\[ApplicationName].exe
    8. Click Ok to finish configuring nmake.
    9. Create a file with an extension of .pro
    10. Depending on the desired type of project, copy the corresponding example into the .pro file (replacing ApplicationName with the application’s name):
      GUI Application:

      TEMPLATE  += app
      CONFIG    += qt warn_on no_keywords embed_manifest_exe
      QT        +=
      TARGET     = ApplicationName
      SOURCES    = 
      HEADERS    =
      LIBS      +=
       
       
      # Treat warnings as errors
      win32:QMAKE_CXXFLAGS += /WX
       
      CONFIG(debug, debug|release){
      	# Debug build options
      	# Enable a read-only console window (i.e. for printf etc.)
      	# CONFIG   += console
      }
      else{
      	# Release build options
      	# Enable a read-only console window (i.e. for printf etc.)
      	# CONFIG   += console
      }

      Console application:

      TEMPLATE  += app
      CONFIG	  += qt warn_on no_keywords console embed_manifest_exe
      QT        +=
      TARGET     = ApplicationName
      SOURCES	   =
      HEADERS	   =
      LIBS      +=
       
       
      # Treat warnings as errors
      win32:QMAKE_CXXFLAGS += /WX
       
      CONFIG(debug, debug|release){
      	# Debug build options
      }
      else{
      	# Release build options
      }

      DLL:

      TEMPLATE  += lib
      CONFIG	  += qt warn_on no_keywords dll embed_manifest_dll
      QT        +=
      TARGET     = ApplicationName
      SOURCES	   = 
      HEADERS	   =
      LIBS      +=
       
       
      # Treat warnings as errors
      win32:QMAKE_CXXFLAGS += /WX
       
      CONFIG(debug, debug|release){
      	# Debug build options
      }
      else{
      	# Release build options
      }

      Static Library:

      TEMPLATE  += lib
      CONFIG	  += qt warn_on no_keywords staticlib
      QT        +=
      TARGET     = ApplicationName
      SOURCES	   = 
      HEADERS	   =
      LIBS      +=
       
       
      # Treat warnings as errors
      win32:QMAKE_CXXFLAGS += /WX
       
      CONFIG(debug, debug|release){
      	# Debug build options
      }
      else{
      	# Release build options
      }

      Qt Plugin:

      TEMPLATE  += lib
      CONFIG	  += qt warn_on no_keywords plugin
      QT        +=
      TARGET     = ApplicationName
      SOURCES	   = 
      HEADERS	   =
      LIBS      +=
       
       
      # Treat warnings as errors
      win32:QMAKE_CXXFLAGS += /WX
       
      CONFIG(debug, debug|release){
      	# Debug build options
      }
      else{
      	# Release build options
      }

      If the Qt project will be linked against static libraries that will undergo development at the same time as the application, add the following to the .pro file:

       CONFIG(debug, debug|release){
      	# Debug build options
              LIBS += path/to/debug/library/library.lib
              POST_TARGETDEPS += $$LIBS
        }
        else{
      	# Release build options
              LIBS += path/to/release/library/library.lib
              POST_TARGETDEPS += $$LIBS
        }
    11. Create and fill in the application’s source files. Each source and header file needs to be listed in the appropriate sections of the applications .pro file (HEADERS and SOURCES). Make sure to always updates this file when new header files and source files are added to the project. Additionally, this approach requires frequently rebuilding of the entire project to ensure that everything is up to date.

5. External References

Official Qt 4.8 Documentation
Official QT Website
Qt Centre – A Qt Community Wiki and forum
QtNode – A Qt Community Wiki