13 quitAction->setShortcut(
tr(
"Ctrl+Q"));
18 removeAction = itemsMenu->addAction(
tr(
"&Remove Item"));
20 itemsMenu->addSeparator();
21 ascendingAction = itemsMenu->addAction(
tr(
"Sort in &Ascending Order"));
22 descendingAction = itemsMenu->addAction(
tr(
"Sort in &Descending Order"));
23 autoSortAction = itemsMenu->addAction(
tr(
"&Automatically Sort Items"));
24 autoSortAction->setCheckable(
true);
25 itemsMenu->addSeparator();
26 QAction *findItemsAction = itemsMenu->addAction(
tr(
"&Find Items"));
27 findItemsAction->setShortcut(
tr(
"Ctrl+F"));
34 QTreeWidget *treeWidget = new QTreeWidget(this);
42 headers <<
tr(
"Subject") <<
tr(
"Default");
63void MainWindow::setupTreeItems()
67 cities->setText(0,
tr(
"Cities"));
69 osloItem->setText(0,
tr(
"Oslo"));
70 osloItem->setText(1,
tr(
"Yes"));
80 planets->setText(0,
tr(
"Planets"));
86 earthItem->setText(0,
tr(
"Earth"));
87 earthItem->setText(1,
tr(
"Yes"));
97void MainWindow::findItems()
100 tr(
"Text to find (including wildcards):"));
120void MainWindow::insertItem()
128 tr(
"Input text for the new item:"));
143 newItem->setText(0, itemText);
146void MainWindow::removeItem()
168void MainWindow::sortAscending()
173void MainWindow::sortDescending()
184void MainWindow::updateSortItems()
186 ascendingAction->setEnabled(!autoSortAction->isChecked());
187 descendingAction->setEnabled(!autoSortAction->isChecked());
The QAction class provides an abstraction for user commands that can be added to different user inter...
void triggered(bool checked=false)
This signal is emitted when an action is activated by the user; for example, when the user clicks a m...
void setSelected(bool selected)
If selected is true and this item is selectable, this item is selected; otherwise,...
void setCentralWidget(QWidget *widget)
Sets the given widget to be the main window's central widget.
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void setSortingEnabled(bool enable)
insertRed setText("insert red text")