Documentation: Port code snippets to new connection syntax

Task-number: PYSIDE-2182
Change-Id: I5f800cf3a4a7afefbc36a79372fc35449fa953f0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 8fccba0e63f9484866398e77a7e8ee54ed80a0a2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Friedemann Kleint 2023-01-10 08:07:58 +01:00 committed by Qt Cherry-pick Bot
parent 23475c7cf1
commit 8b47858231
7 changed files with 22 additions and 27 deletions

View File

@ -8,7 +8,7 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTimer::singleShot(600000, &app, SLOT(quit()));
QTimer::singleShot(600000, &app, QCoreApplication::quit);
...
return app.exec();
}

View File

@ -32,7 +32,7 @@ void Wrapper::wrapper() {
//! [2]
QMenu *file = new QMenu(this);
file->addAction(tr("&Open..."), QKeySequence(tr("Ctrl+O", "File|Open")),
this, SLOT(open()));
this, &MainWindow::open);
//! [2]
} // Wrapper::wrapper

View File

@ -13,17 +13,17 @@ MainWindow::MainWindow()
QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(tr("E&xit"), QKeySequence(tr("Ctrl+Q", "File|Exit")),
this, SLOT(close()));
this, &QWidget::close);
QMenu *actionsMenu = new QMenu(tr("&Actions"));
actionsMenu->addAction(tr("&Highlight List Items"),
this, SLOT(highlightListItems()));
actionsMenu->addAction(tr("&Show Current List"), this, SLOT(showList()));
this, &MainWindow::highlightListItems);
actionsMenu->addAction(tr("&Show Current List"), this, &MainWindow::showList);
QMenu *insertMenu = new QMenu(tr("&Insert"));
insertMenu->addAction(tr("&List"), QKeySequence(tr("Ctrl+L", "Insert|List")),
this, SLOT(insertList()));
this, &MainWindow::insertList);
menuBar()->addMenu(fileMenu);
menuBar()->addMenu(insertMenu);

View File

@ -9,30 +9,30 @@ MainWindow::MainWindow()
QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(tr("&Open..."), QKeySequence(tr("Ctrl+O", "File|Open")),
this, SLOT(openFile()));
this, &MainWindow::openFile);
QAction *quitAction = fileMenu->addAction(tr("E&xit"), this, SLOT(close()));
QAction *quitAction = fileMenu->addAction(tr("E&xit"), this, &MainWindow::close);
quitAction->setShortcut(tr("Ctrl+Q"));
QMenu *editMenu = new QMenu(tr("&Edit"));
cutAction = editMenu->addAction(tr("Cu&t"), this, SLOT(cutSelection()));
cutAction = editMenu->addAction(tr("Cu&t"), this, &MainWindow::cutSelection);
cutAction->setShortcut(tr("Ctrl+X"));
cutAction->setEnabled(false);
copyAction = editMenu->addAction(tr("&Copy"), this, SLOT(copySelection()));
copyAction = editMenu->addAction(tr("&Copy"), this, &MainWindow::copySelection);
copyAction->setShortcut(tr("Ctrl+C"));
copyAction->setEnabled(false);
pasteAction = editMenu->addAction(tr("&Paste"), this, SLOT(pasteSelection()));
pasteAction = editMenu->addAction(tr("&Paste"), this, &MainWindow::pasteSelection);
pasteAction->setShortcut(tr("Ctrl+V"));
pasteAction->setEnabled(false);
QMenu *selectMenu = new QMenu(tr("&Select"));
selectMenu->addAction(tr("&Word"), this, SLOT(selectWord()));
selectMenu->addAction(tr("&Line"), this, SLOT(selectLine()));
selectMenu->addAction(tr("&Block"), this, SLOT(selectBlock()));
selectMenu->addAction(tr("&Frame"), this, SLOT(selectFrame()));
selectMenu->addAction(tr("&Word"), this, &MainWindow::selectWord);
selectMenu->addAction(tr("&Line"), this, &MainWindow::selectLine);
selectMenu->addAction(tr("&Block"), this, &MainWindow::selectBlock);
selectMenu->addAction(tr("&Frame"), this, &MainWindow::selectFrame);
menuBar()->addMenu(fileMenu);
menuBar()->addMenu(editMenu);

View File

@ -6,8 +6,7 @@ void MyObject::lookupServers()
{
// Create a DNS lookup.
dns = new QDnsLookup(this);
connect(dns, SIGNAL(finished()),
this, SLOT(handleServers()));
connect(dns, &QDnsLookup::finished, this, &MyObject::handleServers);
// Find the XMPP servers for gmail.com
dns->setType(QDnsLookup::SRV);

View File

@ -3,12 +3,10 @@
//! [0]
// To find the IP address of qt-project.org
QHostInfo::lookupHost("qt-project.org",
this, SLOT(printResults(QHostInfo)));
QHostInfo::lookupHost("qt-project.org", this, &MyWidget::printResults);
// To find the host name for 4.2.2.1
QHostInfo::lookupHost("4.2.2.1",
this, SLOT(printResults(QHostInfo)));
QHostInfo::lookupHost("4.2.2.1", this, &MyWidget::printResults);
//! [0]
@ -18,8 +16,7 @@ QHostInfo info = QHostInfo::fromName("qt-project.org");
//! [2]
QHostInfo::lookupHost("www.kde.org",
this, SLOT(lookedUp(QHostInfo)));
QHostInfo::lookupHost("www.kde.org", this, &MyWidget::lookedUp);
//! [2]
@ -39,8 +36,7 @@ void MyWidget::lookedUp(const QHostInfo &host)
//! [4]
QHostInfo::lookupHost("4.2.2.1",
this, SLOT(lookedUp(QHostInfo)));
QHostInfo::lookupHost("4.2.2.1", this, &MyWidget::lookedUp);
//! [4]

View File

@ -5,7 +5,7 @@ using namespace Qt::StringLiterals;
//! [0]
QSslSocket *socket = new QSslSocket(this);
connect(socket, SIGNAL(encrypted()), this, SLOT(ready()));
connect(socket, &QSslSocket::encrypted, this, &Receiver::ready);
socket->connectToHostEncrypted("imap.example.com", 993);
//! [0]
@ -42,7 +42,7 @@ while (socket.waitForReadyRead())
//! [3]
QSslSocket socket;
connect(&socket, SIGNAL(encrypted()), receiver, SLOT(socketEncrypted()));
connect(&socket, &QSslSocket::encrypted, receiver, &Receiver::socketEncrypted);
socket.connectToHostEncrypted("imap", 993);
socket->write("1 CAPABILITY\r\n");