Qt5 Port of Examples for the Book Advanced Qt Programming

August 10, 2013

The examples were ported by Walter Dale, and these are his notes. I (Mark Summerfield), haven't had time to do anything except put the examples and these notes on my web site.


The table below summarizes the results of porting to Qt5.

 

All examples were compiled and executed under Qt5.1.0.

 

Comments were inserted (e.g. “added for Qt5”) so that you can search for “Qt5” and find all of the changes. In some examples, screenshots can be found that provide additional information; when you put the examples into final form, the screenshots will have to be deleted.

 

The items in the table marked “OK” required only a “QT +=” statement added to the “.pro” file plus another “#include” added to main.

 

For the items marked “OK, code changed for Qt5”, the changes are commented in the source code with “Qt5” as noted above.

 

The item petridish2 runs OK but hangs when “Quit” is clicked. There’s more detail in the table below. This requires more research.

 

A few compile-time problems remain based on the following three issues. These will require more research:

 

(1) playmusic and playvideo require Phonon which has been replaced in Qt5 by QtMultimedia. The conversion of these two examples would require some rewrite of the code plus the revision of Chapter 2.

 

(2) outputsampler will have to change (mainwindow.cpp:262: error: 'PostScriptFormat' is not a member of 'QPrinter') because PostScript is not supported in Qt5. The example has to be changed and this would require revisions to Chapter 10.

 

(3) pagedesigner1 and pagedesigner2 have an error, (qvariant.h:471: error: 'QVariant::QVariant(Qt::BrushStyle)' is private).

 

Where it might help, the problems were captured in screenshots and stored in the respective example’s folder.

 

This is not a 100% port, but it’s close.

 

Page

Example

Test Result

Comment

7

weathertrayicon

OK

 

9

browserwindow

OK

Some diagnostics appear in the console screenshot

9

option_parser

OK

No changes needed

15

aqp

OK

No changes needed

20

rsspanel

OK

 

31

nyrbviewer

OK

 

44

matrixquiz

OK

 

54

moviejingle

OK

 

64

 

playmusic

 

compile problem

 

Unknown module(s) in QT. Phonon has been replaced in Qt5 by QtMultimedia .

Conversion of examples to QtMultimedia would require revisions to Chapter 2.

80

playvideo

compile problem

Same comments as playmusic, above.

90

zipcodes1

OK

 

113

 

zipcodes2

 

OK, code changed

 

tablemodel.cpp:208: error: 'reset' was not declared in this scope, see screenshots

QT5 states: Use beginResetModel() and endResetModel() instead.

130

 

timelog1

 

OK, code changed

 

richtextlineedit.cpp:218: error: 'escape' is not a member of 'Qt', obsoleted for Qt5

treemodel.cpp:466 and 488: error: 'reset' was not declared in this scope, fixed

151

timelog2

OK, code changed

Same comments as timelog1, above.

188

folderview

OK

 

208

tiledlistview

OK

 

224

censusvisualizer

OK

 

249

image2image

OK

QT += widgets concurrent #added for Qt5

263

numbergrid

OK

 

287

 

crossfader

 

OK, code changed

 

mainwindow.cpp:160: error: 'storageLocation' is not a member of 'QDesktopServices'

The Qt5 QStandardPaths::PicturesLocation has replaced it.

302

findduplicates

OK

 

322

xmledit

OK

 

353

textedit

OK

 

361

 

outputsampler

 

compile problem

 

mainwindow.cpp:262: error: 'PostScriptFormat' is not a member of 'QPrinter'.

PostScript is not supported in Qt5. Changing example would require revisions to Chapter 10.

392

petridish1

OK

 

469

 

petridish2

 

OK, but…

 

Closing exception after clicking on Quit. When using Qt5.0.2, an assert failure was reported.

Using Qt5.1.0 fixed the assert error, but Quit still has a bug of some kind. See screenshots.

409

 

pagedesigner1

 

compile problem

 

qvariant.h:471: error: 'QVariant::QVariant(Qt::BrushStyle)' is private

This one requires more research.

424

pagedesigner2

compile problem

Same comments as pagedesigner1, above.

481

finddialog

OK