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[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
QTimer::singleShot(600000, &app, SLOT(quit())); QTimer::singleShot(600000, &app, QCoreApplication::quit);
... ...
return app.exec(); return app.exec();
} }

View File

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

View File

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

View File

@ -9,30 +9,30 @@ MainWindow::MainWindow()
QMenu *fileMenu = new QMenu(tr("&File")); QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(tr("&Open..."), QKeySequence(tr("Ctrl+O", "File|Open")), 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")); quitAction->setShortcut(tr("Ctrl+Q"));
QMenu *editMenu = new QMenu(tr("&Edit")); 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->setShortcut(tr("Ctrl+X"));
cutAction->setEnabled(false); 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->setShortcut(tr("Ctrl+C"));
copyAction->setEnabled(false); 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->setShortcut(tr("Ctrl+V"));
pasteAction->setEnabled(false); pasteAction->setEnabled(false);
QMenu *selectMenu = new QMenu(tr("&Select")); QMenu *selectMenu = new QMenu(tr("&Select"));
selectMenu->addAction(tr("&Word"), this, SLOT(selectWord())); selectMenu->addAction(tr("&Word"), this, &MainWindow::selectWord);
selectMenu->addAction(tr("&Line"), this, SLOT(selectLine())); selectMenu->addAction(tr("&Line"), this, &MainWindow::selectLine);
selectMenu->addAction(tr("&Block"), this, SLOT(selectBlock())); selectMenu->addAction(tr("&Block"), this, &MainWindow::selectBlock);
selectMenu->addAction(tr("&Frame"), this, SLOT(selectFrame())); selectMenu->addAction(tr("&Frame"), this, &MainWindow::selectFrame);
menuBar()->addMenu(fileMenu); menuBar()->addMenu(fileMenu);
menuBar()->addMenu(editMenu); menuBar()->addMenu(editMenu);

View File

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

View File

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

View File

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