Examples: Don't use deprecated methods

Change-Id: Ib6e795f6b5bb6a3ac19882a5fb224460ef1fc8ad
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
Olivier Goffart 2012-04-20 16:55:59 +02:00 committed by Qt by Nokia
parent fcec903da7
commit 910b446fb2
14 changed files with 28 additions and 26 deletions

View File

@ -225,7 +225,7 @@ void Window::createFilesTable()
QStringList labels;
labels << tr("Filename") << tr("Size");
filesTable->setHorizontalHeaderLabels(labels);
filesTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
filesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
filesTable->verticalHeader()->hide();
filesTable->setShowGrid(false);

View File

@ -199,7 +199,7 @@ void GraphWidget::drawBackground(QPainter *painter, const QRectF &rect)
QLinearGradient gradient(sceneRect.topLeft(), sceneRect.bottomRight());
gradient.setColorAt(0, Qt::white);
gradient.setColorAt(1, Qt::lightGray);
painter->fillRect(rect.intersect(sceneRect), gradient);
painter->fillRect(rect.intersected(sceneRect), gradient);
painter->setBrush(Qt::NoBrush);
painter->drawRect(sceneRect);

View File

@ -478,7 +478,7 @@ void PieView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlag
for (int column = 0; column < columns; ++column) {
QModelIndex index = model()->index(row, column, rootIndex());
QRegion region = itemRegion(index);
if (!region.intersect(contentsRect).isEmpty())
if (region.intersects(contentsRect))
indexes.append(index);
}
}

View File

@ -107,9 +107,10 @@ void FileListModel::setDirPath(const QString &path)
{
QDir dir(path);
beginResetModel();
fileList = dir.entryList();
fileCount = 0;
reset();
endResetModel();
}
//![0]

View File

@ -61,8 +61,8 @@ int main(int argc, char *argv[])
QTableView *table = new QTableView;
table->setModel(data);
table->setSelectionModel(selections);
table->horizontalHeader()->setMovable(true);
table->verticalHeader()->setMovable(true);
table->horizontalHeader()->setSectionsMovable(true);
table->verticalHeader()->setSectionsMovable(true);
// Set StaticContents to enable minimal repaints on resizes.
table->viewport()->setAttribute(Qt::WA_StaticContents);
page.addWidget(table);

View File

@ -52,8 +52,9 @@ ImageModel::ImageModel(QObject *parent)
//! [1]
void ImageModel::setImage(const QImage &image)
{
beginResetModel();
modelImage = image;
reset();
endResetModel();
}
//! [1]

View File

@ -410,7 +410,7 @@ void MainWindow::updateHeader(QModelIndex, int, int)
void MainWindow::adjustHeader()
{
albumView->hideColumn(0);
albumView->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
albumView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
albumView->resizeColumnToContents(2);
albumView->resizeColumnToContents(3);
}

View File

@ -242,8 +242,8 @@ void MainWindow::changeModel()
treeView->setRootIsDecorated(false);
treeView->header()->hide();
treeView->header()->setStretchLastSection(false);
treeView->header()->setResizeMode(0, QHeaderView::Stretch);
treeView->header()->setResizeMode(1, QHeaderView::ResizeToContents);
treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
treeView->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
contentsLabel->setText(tr("Enter name of your country"));
}
break;

View File

@ -116,10 +116,10 @@ void MainWindow::brushColor()
void MainWindow::brushWidth()
{
bool ok;
const int newWidth = QInputDialog::getInteger(this, tr("Plug & Paint"),
tr("Select brush width:"),
paintArea->brushWidth(),
1, 50, 1, &ok);
const int newWidth = QInputDialog::getInt(this, tr("Plug & Paint"),
tr("Select brush width:"),
paintArea->brushWidth(),
1, 50, 1, &ok);
if (ok)
paintArea->setBrushWidth(newWidth);
}

View File

@ -73,7 +73,7 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter,
}
} else if (filter == tr("Smudge...")) {
bool ok;
int numIters = QInputDialog::getInteger(parent, tr("Smudge Filter"),
int numIters = QInputDialog::getInt(parent, tr("Smudge Filter"),
tr("Enter number of iterations:"),
5, 1, 20, 1, &ok);
if (ok) {
@ -102,7 +102,7 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter,
}
} else if (filter == tr("Threshold...")) {
bool ok;
int threshold = QInputDialog::getInteger(parent, tr("Threshold Filter"),
int threshold = QInputDialog::getInt(parent, tr("Threshold Filter"),
tr("Enter threshold:"),
10, 1, 256, 1, &ok);
if (ok) {

View File

@ -89,7 +89,7 @@ LocationDialog::LocationDialog(QWidget *parent)
locationsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
locationsTable->setColumnCount(2);
locationsTable->setHorizontalHeaderLabels(labels);
locationsTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
locationsTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
locationsTable->horizontalHeader()->resizeSection(1, 180);
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok

View File

@ -51,8 +51,8 @@ SettingsTree::SettingsTree(QWidget *parent)
QStringList labels;
labels << tr("Setting") << tr("Type") << tr("Value");
setHeaderLabels(labels);
header()->setResizeMode(0, QHeaderView::Stretch);
header()->setResizeMode(2, QHeaderView::Stretch);
header()->setSectionResizeMode(0, QHeaderView::Stretch);
header()->setSectionResizeMode(2, QHeaderView::Stretch);
settings = 0;
refreshTimer.setInterval(2000);

View File

@ -285,9 +285,9 @@ void MainWindow::createImagesGroupBox()
imagesTable->horizontalHeader()->setDefaultSectionSize(90);
imagesTable->setColumnCount(3);
imagesTable->setHorizontalHeaderLabels(labels);
imagesTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
imagesTable->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
imagesTable->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
imagesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
imagesTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed);
imagesTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
imagesTable->verticalHeader()->hide();
//! [23]

View File

@ -107,10 +107,10 @@ void MainWindow::penWidth()
//! [9] //! [10]
{
bool ok;
int newWidth = QInputDialog::getInteger(this, tr("Scribble"),
tr("Select pen width:"),
scribbleArea->penWidth(),
1, 50, 1, &ok);
int newWidth = QInputDialog::getInt(this, tr("Scribble"),
tr("Select pen width:"),
scribbleArea->penWidth(),
1, 50, 1, &ok);
if (ok)
scribbleArea->setPenWidth(newWidth);
}