diff options
18 files changed, 718 insertions, 0 deletions
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_phonon-api.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_phonon-api.qdoc new file mode 100644 index 000000000..3f0771e37 --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/code/doc_src_phonon-api.qdoc @@ -0,0 +1,192 @@ +//! [0] +class PushStream (AbstractMediaStream): + def __init__(self, parent = None): + AbstractMediaStream.__init(self, parent) + self.timer = QTimer(self) + self.setStreamSize(self.getMediaStreamSize()) + + self.timer.timeout.connect(self.moreData) + self.timer.setInterval(0) + + @Slot() + def moreData(self): + data = self.getMediaData() + if data.isEmpty(): + self.endOfData() + else: + self.writeData(data) + + def needData(self): + self.timer.start() + self.moreData() + + def enoughData(self): + self.timer.stop() +//! [0] + + +//! [1] +class PushStream (AbstractMediaStream): + def __init__(self, parent = None): + AbstractMediaStream.__init(self, parent) + self.setStreamSize(self.getMediaStreamSize()) + + @Slot() + def needData(self): + data = self.getMediaData() + if data.isEmpty(): + self.endOfData() + else: + self.writeData(data) +//! [1] + + +//! [2] +self.seekStream(0) +//! [2] + + +//! [3] +m = MediaObject() +fileName = "/home/foo/bar.ogg" +url = QUrl("http://www.example.com/stream.mp3") +someBuffer = QBuffer() +m.setCurrentSource(fileName) +m.setCurrentSource(url) +m.setCurrentSource(someBuffer) +m.setCurrentSource(Phonon.Cd) +//! [3] + + +//! [4] +player = VideoPlayer(Phonon.VideoCategory, parentWidget) +player.finished.connect(player.deleteLater) +player.play(url) +//! [4] + + +//! [5] +audioPlayer.load(url) +audioPlayer.play() +//! [5] + + +//! [6] +media = MediaObject(self) +media.finished.connect(self.slotFinished) +media.setCurrentSource("/home/username/music/filename.ogg") + +# ... + +media.play() +//! [6] + + +//! [7] +media.setCurrentSource(":/sounds/startsound.ogg") +media.enqueue("/home/username/music/song.mp3") +media.enqueue(":/sounds/endsound.ogg") +//! [7] + + +//! [8] + media.setCurrentSource(":/sounds/startsound.ogg") + media.aboutToFinish.connect(lambda : media.enqueue("/home/username/music/song.mp3")) +//! [8] + + +//! [9] +x = 200 +media.setTickInterval(x) +assert(x == producer.tickInterval()) +//! [9] + + +//! [10] +x = 200 +media.setTickInterval(x) +assert(x >= producer.tickInterval() and x <= * producer.tickInterval()) +//! [10] + + +//! [11] +//! [12] + self.media.hasVideoChanged[bool].connect(hasVideoChanged) + self.media.setCurrentSource("somevideo.avi") + self.media.hasVideo() # returns false + + @Slot(bool) + def hasVideoChanged(self, b): + # b == true + media.hasVideo() # returns true +//! [12] +//! [11] + +//! [13] +self.setMetaArtist(media.metaData("ARTIST")) +self.setMetaAlbum(media.metaData("ALBUM")) +self.setMetaTitle(media.metaData("TITLE")) +self.setMetaDate(media.metaData("DATE")) +self.setMetaGenre(media.metaData("GENRE")) +self.setMetaTrack(media.metaData("TRACKNUMBER")) +self.setMetaComment(media.metaData("DESCRIPTION")) +//! [13] + + +//! [14] +url = QUrl("http://www.example.com/music.ogg") +media.setCurrentSource(url) +//! [14] + + +//! [15] +progressBar.setRange(0, 100) # this is the default +self.media.bufferStatus[int].connect(progressBar.setValue) +//! [15] + + +//! [16] +BackendCapabilities.notifier.capabilitiesChanged.connect(...) +//! [16] + + +//! [17] +cb = QComboBox(parentWidget) +model = ObjectDescriptionModel(cb) +model.setModelData(BackendCapabilities.availableAudioOutputDevices()) +cb.setModel(model) +cb.setCurrentIndex(0) # select first entry +//! [17] + + +//! [18] +cbIndex = cb.currentIndex() +selectedDevice = model.modelData(cbIndex) +//! [18] + + +//! [19] +path = Phonon.createPath(...) +effect = Effect(this) +path.insertEffect(effect) +//! [19] + + +//! [20] +media = MediaObject() +output = AudioOutput(Phonon.MusicCategory) +path = Phonon.createPath(media, output) +assert(path.isValid()) # for this simple case the path should always be + # valid - there are unit tests to ensure it +# insert an effect +effectList = BackendCapabilities.availableAudioEffects() +if effectList: + effect = path.insertEffect(effectList[0]) +//! [20] + + +//! [21] +media = MediaObject(parent) +vwidget = VideoWidget(parent) +Phonon.createPath(media, vwidget) +//! [21] diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp new file mode 100644 index 000000000..c5d4809bb --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp @@ -0,0 +1,37 @@ +//! [0] +def draw(self, painter): + # Fully opaque draw directly without going through a pixmap. + if qFuzzyCompare(self.opacity, 1): + drawSource(painter) + return + # ... +//! [0] + +//! [1] +def draw(self, painter): + # ... + offset = QPoint() + if self.sourceIsPixmap(): + # No point in drawing in device coordinates (pixmap will be scaled anyways). + pixmap = sourcePixmap(Qt.LogicalCoordinates, offset) + ... + painter.drawPixmap(offset, pixmap) + else: + # Draw pixmap in device coordinates to avoid pixmap scaling + pixmap = sourcePixmap(Qt.DeviceCoordinates, offset) + painter.setWorldTransform(QTransform()) + # ... + painter.drawPixmap(offset, pixmap) + # ... +//! [1] + +//! [2] +# ... +alphaGradient = QLinearGradient(rect.topLeft(), rect.bottomLeft()) +alphaGradient.setColorAt(0.0, Qt.transparent) +alphaGradient.setColorAt(0.5, Qt.black) +alphaGradient.setColorAt(1.0, Qt.transparent) +effect = QGraphicsOpacityEffect() +effect.setOpacityMask(alphaGradient) +# ... +//! [2] diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp new file mode 100644 index 000000000..465fff192 --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp @@ -0,0 +1,15 @@ +//! [0] +def closeEvent(self, event): + settings = QSettings("MyCompany", "MyApp") + settings.setValue("geometry", self.saveGeometry()) + settings.setValue("windowState", self.saveState()) + QMainWindow.closeEvent(self, event) +//! [0] + + +//! [1] +def readSettings(self): + settings = QSettings("MyCompany", "MyApp") + restoreGeometry(settings.value("myWidget/geometry")) + restoreState(settings.value("myWidget/windowState")) +//! [1] diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp new file mode 100644 index 000000000..8d18510ce --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp @@ -0,0 +1,24 @@ +//! [0] +manager = QNetworkAccessManager(self) +diskCache = QNetworkDiskCache(self) +diskCache.setCacheDirectory("cacheDir") +manager.setCache(diskCache) +//! [0] + +//! [1] +# do a normal request (preferred from network, as this is the default) +request = QNetworkRequest(QUrl("http://qt.nokia.com")) +manager.get(request) + +# do a request preferred from cache +request2 = QNetworkRequest(QUrl("http://qt.nokia.com")) +request2.setAttribute(QNetworkRequest.CacheLoadControlAttribute, QNetworkRequest.PreferCache) +manager.get(request2) +//! [1] + +//! [2] +@Slot(QNetworkReply) +def replyFinished(reply): + fromCache = reply.attribute(QNetworkRequest.SourceIsFromCacheAttribute) + print("page from cache? %d" % fromCache) +//! [2] diff --git a/doc/codesnippets/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp b/doc/codesnippets/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp new file mode 100644 index 000000000..837ea03ee --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp @@ -0,0 +1,8 @@ +//! [0] +mgr = QNetworkConfigurationManager() +activeConfigs = mgr.allConfigurations(QNetworkConfiguration.Active) +if activeConfigs: + assert(mgr.isOnline()) +else: + assert(not mgr.isOnline()) +//! [0] diff --git a/doc/codesnippets/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp b/doc/codesnippets/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp new file mode 100644 index 000000000..9c8f35a22 --- /dev/null +++ b/doc/codesnippets/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp @@ -0,0 +1,53 @@ +//! [0] +shader = QGLShader(QGLShader.Vertex) +shader.compileSourceCode(code) + +program = QGLShaderProgram(context) +program.addShader(shader) +program.link() + +program.bind() +//! [0] + +//! [1] +program.addShaderFromSourceCode(QGLShader.Vertex, + "attribute highp vec4 vertex\n" \ + "attribute mediump mat4 matrix\n" \ + "void main(void)\n" \ + "{\n" \ + " gl_Position = matrix * vertex\n" \ + "}") +program.addShaderFromSourceCode(QGLShader.Fragment, + "uniform mediump vec4 color\n" \ + "void main(void)\n" \ + "{\n" \ + " gl_FragColor = color\n" \ + "}") +program.link() +program.bind() + +vertexLocation = program.attributeLocation("vertex") +matrixLocation = program.attributeLocation("matrix") +colorLocation = program.uniformLocation("color") +//! [1] + +//! [2] +triangleVertices = ( + 60.0f, 10.0f, 0.0f, + 110.0f, 110.0f, 0.0f, + 10.0f, 110.0f, 0.0f) + +color = QColor(0, 255, 0, 255) + +pmvMatrix = QMatrix4x4() +pmvMatrix.ortho(self.rect()) + +program.enableAttributeArray(vertexLocation) +program.setAttributeArray(vertexLocation, triangleVertices, 3) +program.setUniformValue(matrixLocation, pmvMatrix) +program.setUniformValue(colorLocation, color) + +glDrawArrays(GL_TRIANGLES, 0, 3) + +program.disableAttributeArray(vertexLocation) +//! [2] diff --git a/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml b/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml new file mode 100644 index 000000000..5f4c99b03 --- /dev/null +++ b/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml @@ -0,0 +1,9 @@ +import QtQuick 1.0 +import "ImageProviderCore" // import the plugin that registers the color image provider + +//![0] +Column { + Image { source: "image://colors/yellow" } + Image { source: "image://colors/red" } +} +//![0] diff --git a/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp b/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp new file mode 100644 index 000000000..b35f27961 --- /dev/null +++ b/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp @@ -0,0 +1,23 @@ + +//! [adding a corner anchor in two steps] +layout.addAnchor(a, Qt.AnchorTop, layout, Qt.AnchorTop) +layout.addAnchor(a, Qt.AnchorLeft, layout, Qt.AnchorLeft) +//! [adding a corner anchor in two steps] + +//! [adding a corner anchor] +layout.addCornerAnchors(a, Qt.TopLeftCorner, layout, Qt.TopLeftCorner) +//! [adding a corner anchor] + +//! [adding anchors] +layout.addAnchor(b, Qt.AnchorLeft, a, Qt.AnchorRight) +layout.addAnchor(b, Qt.AnchorTop, a, Qt.AnchorBottom) +//! [adding anchors] + +//! [adding anchors to match sizes in two steps] +layout.addAnchor(b, Qt.AnchorLeft, c, Qt.AnchorLeft) +layout.addAnchor(b, Qt.AnchorRight, c, Qt.AnchorRight) +//! [adding anchors to match sizes in two steps] + +//! [adding anchors to match sizes] +layout.addAnchors(b, c, Qt.Horizontal) +//! [adding anchors to match sizes] diff --git a/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp b/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp new file mode 100644 index 000000000..6e1236e16 --- /dev/null +++ b/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp @@ -0,0 +1,11 @@ + +//! [implicit tr context] +def createMenus(self): + fileMenu = menuBar().addMenu("&File") +//! [implicit tr context] + +//! [0] + fileToolBar = addToolBar("File") + fileToolBar.addAction(newAct) + fileToolBar.addAction(openAct) +//! [0] diff --git a/doc/codesnippets/examples/widgets/groupbox/window.cpp b/doc/codesnippets/examples/widgets/groupbox/window.cpp new file mode 100644 index 000000000..688f02ac1 --- /dev/null +++ b/doc/codesnippets/examples/widgets/groupbox/window.cpp @@ -0,0 +1,138 @@ + +//! [0] +def __init__(self, parent = None): + QWidget.__init__(self, parent) + + grid = QGridLayout() + grid.addWidget(createFirstExclusiveGroup(), 0, 0) + grid.addWidget(createSecondExclusiveGroup(), 1, 0) + grid.addWidget(createNonExclusiveGroup(), 0, 1) + grid.addWidget(createPushButtonGroup(), 1, 1) + setLayout(grid) + + setWindowTitle("Group Boxes") + resize(480, 320) + +//! [0] + +//! [1] +def createFirstExclusiveGroup(self): +//! [2] + groupBox = QGroupBox("Exclusive Radio Buttons") + + radio1 = QRadioButton("&Radio button 1") + radio2 = QRadioButton("R&adio button 2") + radio3 = QRadioButton("Ra&dio button 3") + + radio1.setChecked(True) +//! [1] //! [3] + + vbox = QVBoxLayout() + vbox.addWidget(radio1) + vbox.addWidget(radio2) + vbox.addWidget(radio3) + vbox.addStretch(1) + groupBox.setLayout(vbox) +//! [2] + return groupBox +//! [3] + +//! [4] +def createSecondExclusiveGroup(self): + groupBox = QGroupBox("E&xclusive Radio Buttons") + groupBox.setCheckable(True) + groupBox.setChecked(False) +//! [4] + +//! [5] + radio1 = QRadioButton("Rad&io button 1") + radio2 = QRadioButton("Radi&o button 2") + radio3 = QRadioButton("Radio &button 3") + radio1.setChecked(True) + checkBox = QCheckBox("Ind&ependent checkbox") + checkBox.setChecked(True) +//! [5] + +//! [6] + vbox = QVBoxLayout() + vbox.addWidget(radio1) + vbox.addWidget(radio2) + vbox.addWidget(radio3) + vbox.addWidget(checkBox) + vbox.addStretch(1) + groupBox.setLayout(vbox) + + return groupBox +//! [6] + +//! [7] +def createNonExclusiveGroup(self): + groupBox = QGroupBox("Non-Exclusive Checkboxes") + groupBox.setFlat(True) +//! [7] + +//! [8] + checkBox1 = QCheckBox("&Checkbox 1") + checkBox2 = QCheckBox("C&heckbox 2") + checkBox2.setChecked(True) + tristateBox = QCheckBox("Tri-&state button") + tristateBox.setTristate(True) +//! [8] + tristateBox.setCheckState(Qt.PartiallyChecked) + +//! [9] + vbox = QVBoxLayout() + vbox.addWidget(checkBox1) + vbox.addWidget(checkBox2) + vbox.addWidget(tristateBox) + vbox.addStretch(1) + groupBox.setLayout(vbox) + + return groupBox +//! [9] + +//! [10] +def createPushButtonGroup(self): + groupBox = QGroupBox("&Push Buttons") + groupBox.setCheckable(True) + groupBox.setChecked(True) +//! [10] + +//! [11] + pushButton = QPushButton("&Normal Button") + toggleButton = QPushButton("&Toggle Button") + toggleButton.setCheckable(True) + toggleButton.setChecked(True) + flatButton = QPushButton("&Flat Button") + flatButton.setFlat(True) +//! [11] + +//! [12] + popupButton = QPushButton("Pop&up Button") + menu = QMenu(self) + menu.addAction("&First Item") + menu.addAction("&Second Item") + menu.addAction("&Third Item") + menu.addAction("F&ourth Item") + popupButton.setMenu(menu) +//! [12] + + newAction = menu.addAction("Submenu") + QMenu *subMenu = QMenu("Popup Submenu") + subMenu.addAction("Item 1") + subMenu.addAction("Item 2") + subMenu.addAction("Item 3") + newAction.setMenu(subMenu) + +//! [13] + vbox = QVBoxLayout() + vbox.addWidget(pushButton) + vbox.addWidget(toggleButton) + vbox.addWidget(flatButton) + vbox.addWidget(popupButton) + vbox.addStretch(1) + groupBox.setLayout(vbox) + + return groupBox +} +//! [13] diff --git a/doc/codesnippets/snippets/customstyle/main.cpp b/doc/codesnippets/snippets/customstyle/main.cpp new file mode 100644 index 000000000..a1ac4acaa --- /dev/null +++ b/doc/codesnippets/snippets/customstyle/main.cpp @@ -0,0 +1,12 @@ + +//! [using a custom style] +import sys +from PySide.QtGui import * + +QApplication.setStyle(CustomStyle()) +app = QApplication(sys.argv) +spinBox = QSpinBox() +spinBox.show() +sys.exit(app.exec_()) + +//! [using a custom style] diff --git a/doc/codesnippets/snippets/phonon.cpp b/doc/codesnippets/snippets/phonon.cpp new file mode 100644 index 000000000..950fe249b --- /dev/null +++ b/doc/codesnippets/snippets/phonon.cpp @@ -0,0 +1,39 @@ + +//![0] +music = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource("/path/mysong.wav")) +music.play() +//![0] + +parentWidget = QWidget() +url = QUrl("Myfancymusic") + +//![1] +player = Phonon.VideoPlayer(Phonon.VideoCategory, parentWidget) +player.play(url) +//![1] + +//![2] +mediaObject = Phonon.MediaObject(self) +mediaObject.setCurrentSource(Phonon.MediaSource("/mymusic/barbiegirl.wav")) +audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self) +path = Phonon.createPath(mediaObject, audioOutput) +//![2] + +//![3] +effect = Phonon.Effect(Phonon.BackendCapabilities.availableAudioEffects()[0], self) +path.insertEffect(effect) +//![3] + +//![4] +mediaObject = Phonon.MediaObject(self) + +videoWidget = Phonon.VideoWidget(self) +Phonon.createPath(mediaObject, videoWidget) + +audioOutput = Phonon.AudioOutput(Phonon.VideoCategory, self) +Phonon.createPath(mediaObject, audioOutput) +//![4] + +//![5] +mediaObject.play() +//![5] diff --git a/doc/codesnippets/snippets/phonon/samplebackend/main.cpp b/doc/codesnippets/snippets/phonon/samplebackend/main.cpp new file mode 100644 index 000000000..555f93b41 --- /dev/null +++ b/doc/codesnippets/snippets/phonon/samplebackend/main.cpp @@ -0,0 +1,66 @@ + +//! [snippet] +def createObject(self, c, parent, args): + if c == BackendInterface.MediaObjectClass: + return MediaObject(parent) + elif c == BackendInterface.VolumeFaderEffectClass: + return VolumeFaderEffect(parent) + elif c == BackendInterface.AudioOutputClass: + return AudioOutput(parent) + elif c == BackendInterface.AudioDataOutputClass: + return AudioDataOutput(parent) + elif c == BackendInterface.VisualizationClass: + return Visualization(parent) + elif c == BackendInterface.VideoDataOutputClass: + return VideoDataOutput(parent) + elif c == BackendInterface.EffectClass: + return Effect(args[0].toInt(), parent) + elif c == BackendInterface.VideoWidgetClass: + return VideoWidget(parent) + return None + +def objectDescriptionIndexes(self, type_): + retval = set() + + if type_ == Phonon.AudioOutputDeviceType: + # use AudioDeviceEnumerator to list ALSA and OSS devices + retval.add(10000) + retval.add(10001) + elif type_ == Phonon.AudioCaptureDeviceType: + retval.add(20000) + retval.add(20001) + elif type_ == Phonon.VideoCaptureDeviceType: + retval.add(30000) + retval.add(30001) + elif type_ == Phonon.EffectType: + retval.add(0x7F000001) + return retval + +def objectDescriptionProperties(self, type_, index): + ret = {} + if type_ == Phonon.AudioOutputDeviceType: + if index == 10000: + ret["name"] = "internal Soundcard" + elif index == 10001: + ret["name"] = "USB Headset" + ret["available"] = False + elif type_ == Phonon.AudioCaptureDeviceType: + if index == 20000: + ret["name"] = "Soundcard" + ret["description"] = "first description" + elif index == 20001: + ret["name"] = "DV" + ret["description"] = "second description" + elif type_ == Phonon.VideoCaptureDeviceType: + elif index == 30000: + ret["name"] = "USB Webcam" + ret["description"] = "first description" + elif index == 30001: + ret["name"] = "DV")) + ret["description"] = "second description" + elif type_ == Phonon.EffectType: + if index == 0x7F000001: + ret["name"] = "Delay" + ret["description"] = "Simple delay effect with time, feedback and level controls." + return ret +//! [snippet] diff --git a/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp new file mode 100644 index 000000000..c8245b6c0 --- /dev/null +++ b/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp @@ -0,0 +1,11 @@ + +def wrapInFunction(): +//! [0] + # ... + page = QWebPage() + # ... + + inspector = QWebInspector() + inspector.setPage(page) +//! [0] + diff --git a/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp b/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp new file mode 100644 index 000000000..19a68355d --- /dev/null +++ b/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp @@ -0,0 +1,31 @@ + +def wrapInFunction(): +//! [0] + view.page().history() +//! [0] + + +//! [1] + view.page().settings() +//! [1] + + +//! [2] + view.triggerAction(QWebPage.Copy) +//! [2] + + +//! [3] + view.page().triggerPageAction(QWebPage.Stop) +//! [3] + + +//! [4] + view.page().triggerPageAction(QWebPage.GoBack) +//! [4] + + +//! [5] + view.page().triggerPageAction(QWebPage.GoForward) +//! [5] + diff --git a/doc/codesnippets/webkitsnippets/webpage/main.cpp b/doc/codesnippets/webkitsnippets/webpage/main.cpp new file mode 100644 index 000000000..4fa194945 --- /dev/null +++ b/doc/codesnippets/webkitsnippets/webpage/main.cpp @@ -0,0 +1,33 @@ +//! [0] +class Thumbnailer (QObject): + def __init__(self, url): +//! [1] + QObject.__init__(self) + self.page = QWebPage() + self.page.mainFrame().load(url) + page.loadFinished[bool].connect(self.render) +//! [1] + + finished = Signal() + +//! [2] + def render(self): + self.page.setViewportSize(self.page.mainFrame().contentsSize()) + image = QImage(self.page.viewportSize(), QImage.Format_ARGB32) + painter = QPainter(image) + + self.page.mainFrame().render(painter) + painter.end() + + thumbnail = image.scaled(400, 400) + thumbnail.save("thumbnail.png") + + self.finished.emit() +//! [2] +//! [0] + +app = QApplication(sys.argv) + +thumbnail = Thumbnailer(QUrl("http://qt.nokia.com")) +thumbnail.finished.connect(app.quit) +sys.exit(app.exec_()) diff --git a/doc/extras/PySide.QtTest.rst b/doc/extras/PySide.QtTest.rst new file mode 100644 index 000000000..d5963cb5a --- /dev/null +++ b/doc/extras/PySide.QtTest.rst @@ -0,0 +1,7 @@ +To include the definitions of the module's classes, use the following directive: + +:: + + import PySide.QtTest + +.. note:: All macros in the C++ version of QtTest were not binded in PySide, this module is useful only for GUI testing and benchmarking, for ordinary unit testing you should use the ``unittest`` Python module. diff --git a/doc/extras/PySide.QtUiTools.rst b/doc/extras/PySide.QtUiTools.rst new file mode 100644 index 000000000..c8558f2d1 --- /dev/null +++ b/doc/extras/PySide.QtUiTools.rst @@ -0,0 +1,9 @@ +These forms are processed at run-time to produce dynamically-generated user interfaces. In order to generate a form at run-time, a resource file containing a UI file is needed. + +A form loader object, provided by the QUiLoader class, is used to construct the user interface. This user interface can be retrieved from any QIODevice; for example, a QFile object can be used to obtain a form stored in a project's resources. The :meth:`PySide.QtUiTools.QUiLoader.load` function takes the user interface description contained in the file and constructs the form widget. + +To include the definitions of the module's classes, use the following directive: + +:: + + import PySide..QtUiTools |