Fixed some code snippets used in the PySide docs.

This commit is contained in:
Hugo Parente Lima 2010-10-05 14:55:20 -03:00
commit 1508831725
8 changed files with 28 additions and 28 deletions

View file

@ -60,14 +60,14 @@ def __init__(self, parent):
//! [3] //! [3]
def accept(self): def accept(self):
//! [3] //! [4] //! [3] //! [4]
className = self.field("className").toByteArray() className = self.field("className")
baseClass = self.field("baseClass").toByteArray() baseClass = self.field("baseClass")
macroName = self.field("macroName").toByteArray() macroName = self.field("macroName")
baseInclude = self.field("baseInclude").toByteArray() baseInclude = self.field("baseInclude")
outputDir = self.field("outputDir").toString() outputDir = self.field("outputDir")
header = self.field("header").toString() header = self.field("header")
implementation = self.field("implementation").toString() implementation = self.field("implementation")
//! [4] //! [4]
... ...
@ -223,17 +223,17 @@ class CodeStylePage(QWizardPage):
//! [16] //! [16]
def initializePage(self): def initializePage(self):
className = self.field("className").toString() className = self.field("className")
self.macroNameLineEdit.setText(className.toUpper() + "_H") self.macroNameLineEdit.setText(className.toUpper() + "_H")
baseClass = self.field("baseClass").toString() baseClass = self.field("baseClass")
self.includeBaseCheckBox.setChecked(not baseClass.isEmpty()) self.includeBaseCheckBox.setChecked(len(baseClass))
self.includeBaseCheckBox.setEnabled(not baseClass.isEmpty()) self.includeBaseCheckBox.setEnabled(len(baseClass))
self.baseIncludeLabel.setEnabled(not baseClass.isEmpty()) self.baseIncludeLabel.setEnabled(len(baseClass))
self.baseIncludeLineEdit.setEnabled(not baseClass.isEmpty()) self.baseIncludeLineEdit.setEnabled(len(baseClass))
if baseClass.isEmpty(): if not baseClass:
self.baseIncludeLineEdit.clear() self.baseIncludeLineEdit.clear()
elsif QRegExp("Q[A-Z].*").exactMatch(baseClass): elsif QRegExp("Q[A-Z].*").exactMatch(baseClass):
baseIncludeLineEdit.setText("<" + baseClass + ">") baseIncludeLineEdit.setText("<" + baseClass + ">")

View file

@ -78,7 +78,7 @@ def __init__(self, parent):
//! [3] //! [3]
connect(moreButton, SIGNAL("toggled(bool)"), extension, SLOT("setVisible(bool)")) connect(moreButton, SIGNAL("toggled(bool)"), extension, SLOT("setVisible(bool)"))
QVBoxLayout *extensionLayout = QVBoxLayout extensionLayout = QVBoxLayout()
extensionLayout.setMargin(0) extensionLayout.setMargin(0)
extensionLayout.addWidget(wholeWordsCheckBox) extensionLayout.addWidget(wholeWordsCheckBox)
extensionLayout.addWidget(backwardCheckBox) extensionLayout.addWidget(backwardCheckBox)
@ -87,17 +87,17 @@ def __init__(self, parent):
//! [3] //! [3]
//! [4] //! [4]
topLeftLayout = QHBoxLayout topLeftLayout = QHBoxLayout()
topLeftLayout.addWidget(label) topLeftLayout.addWidget(label)
topLeftLayout.addWidget(lineEdit) topLeftLayout.addWidget(lineEdit)
leftLayout = QVBoxLayout leftLayout = QVBoxLayout()
leftLayout.addLayout(topLeftLayout) leftLayout.addLayout(topLeftLayout)
leftLayout.addWidget(caseCheckBox) leftLayout.addWidget(caseCheckBox)
leftLayout.addWidget(fromStartCheckBox) leftLayout.addWidget(fromStartCheckBox)
leftLayout.addSself.tretch(1) leftLayout.addSself.tretch(1)
mainLayout = QGridLayout mainLayout = QGridLayout()
mainLayout.setSizeConsself.traint(QLayout.SetFixedSize) mainLayout.setSizeConsself.traint(QLayout.SetFixedSize)
mainLayout.addLayout(leftLayout, 0, 0) mainLayout.addLayout(leftLayout, 0, 0)
mainLayout.addWidget(buttonBox, 0, 1) mainLayout.addWidget(buttonBox, 0, 1)

View file

@ -83,7 +83,7 @@ void LicenseWizard::showHelp()
{ {
static QString lastHelpMessage; static QString lastHelpMessage;
QString message; message = ""
switch (currentId()) { switch (currentId()) {
case Page_Intro: case Page_Intro:

View file

@ -63,9 +63,9 @@
//! [2] //! [2]
//! [3] //! [3]
QString text = QInputDialog::getText(self, self.tr("QInputDialog().getText()"), text = QInputDialog::getText(self, self.tr("QInputDialog().getText()"),
self.tr("User name:"), QLineEdit.Normal, self.tr("User name:"), QLineEdit.Normal,
QDir().home().dirName(), ok) QDir().home().dirName(), ok)
if ok and not text.isEmpty(): if ok and text:
textLabel.setText(text) textLabel.setText(text)
//! [3] //! [3]

View file

@ -113,7 +113,7 @@ def createConclusionPage(self):
def main(): def main():
app = QApplication(sys.argv) app = QApplication(sys.argv)
translatorFileName = QLatin1String("qt_") translatorFileName = "qt_"
translatorFileName += QLocale.system().name() translatorFileName += QLocale.system().name()
translator = QTranslator(app) translator = QTranslator(app)
if translator.load(translatorFileName, QLibraryInfo.location(QLibraryInfo.TranslationsPath)): if translator.load(translatorFileName, QLibraryInfo.location(QLibraryInfo.TranslationsPath)):

View file

@ -68,9 +68,9 @@ def setData(self, index, value, role):
ok = False ok = False
if index.column() == 1: if index.column() == 1:
ok = self.setFirstName(id, value.toString()) ok = self.setFirstName(id, value)
else: else:
ok = self.setLastName(id, value.toString()) ok = self.setLastName(id, value)
self.refresh() self.refresh()
return ok return ok
} }

View file

@ -100,11 +100,11 @@ def main():
createRelationalTables() createRelationalTables()
QSqlRelationalTableModel model model = QSqlRelationalTableModel()
initializeModel(&model) initializeModel(model)
view = createView(QObject.tr("Relational Table Model"), &model) view = createView(QObject.tr("Relational Table Model"), model)
view.show() view.show()
return app.exec_() return app.exec_()

View file

@ -59,7 +59,7 @@ int main(int argc, char *argv[])
//! [Adding a resource] //! [Adding a resource]
document.addResource(QTextDocument.ImageResource, document.addResource(QTextDocument.ImageResource,
QUrl("mydata://image.png"), QVariant(image)) QUrl("mydata://image.png"), image)
//! [Adding a resource] //! [Adding a resource]
//! [Inserting an image with a cursor] //! [Inserting an image with a cursor]