本文整理汇总了C++中QAbstractButton::setToolTip方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractButton::setToolTip方法的具体用法?C++ QAbstractButton::setToolTip怎么用?C++ QAbstractButton::setToolTip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractButton
的用法示例。
在下文中一共展示了QAbstractButton::setToolTip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTabCloseToolTips
void MainWindow::setTabCloseToolTips(QTabWidget *tabs, QString tooltip)
{
QList<QAbstractButton*> allPButtons = tabs->findChildren<QAbstractButton*>();
for (int ind = 0; ind < allPButtons.size(); ind++)
{
QAbstractButton* item = allPButtons.at(ind);
if (item->inherits("CloseButton"))
item->setToolTip(tooltip);
}
}
示例2: insertCloseButton
void ComboTabBar::insertCloseButton(int index)
{
index -= pinnedTabsCount();
if (index < 0) {
return;
}
QAbstractButton* closeButton = new CloseButton(this);
closeButton->setToolTip(m_closeButtonsToolTip);
connect(closeButton, SIGNAL(clicked()), this, SLOT(closeTabFromButton()));
m_mainTabBar->setTabButton(index, closeButtonPosition(), closeButton);
}
示例3: createWidgets
void MusicPlayer::createWidgets()
{
playButton = new QToolButton(this);
playButton->setEnabled(false);
playButton->setToolTip(tr("Play"));
playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
connect(playButton, SIGNAL(clicked()), this, SLOT(togglePlayback()));
QAbstractButton *openButton = new QToolButton(this);
openButton->setText(tr("..."));
openButton->setToolTip(tr("Open a file..."));
openButton->setFixedSize(playButton->sizeHint());
connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));
volumeButton = new VolumeButton(this);
volumeButton->setToolTip(tr("Adjust volume"));
volumeButton->setVolume(mediaPlayer.volume());
connect(volumeButton, SIGNAL(volumeChanged(int)), &mediaPlayer, SLOT(setVolume(int)));
positionSlider = new QSlider(Qt::Horizontal, this);
positionSlider->setEnabled(false);
positionSlider->setToolTip(tr("Seek"));
connect(positionSlider, SIGNAL(valueChanged(int)), this, SLOT(setPosition(int)));
infoLabel = new QLabel(this);
positionLabel = new QLabel(tr("00:00"), this);
positionLabel->setMinimumWidth(positionLabel->sizeHint().width());
QBoxLayout *controlLayout = new QHBoxLayout;
controlLayout->setMargin(0);
controlLayout->addWidget(openButton);
controlLayout->addWidget(playButton);
controlLayout->addWidget(positionSlider);
controlLayout->addWidget(positionLabel);
controlLayout->addWidget(volumeButton);
QBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(infoLabel);
mainLayout->addLayout(controlLayout);
}
示例4: buttonContextMenu
void LaunchPad::buttonContextMenu(const QPoint& /*pos*/)
{
QAbstractButton* btn = static_cast<QAbstractButton*>(sender());
int id = mButtons.id(btn);
QDialog dialog;
QGridLayout layout(&dialog);
QLabel* label;
int row = 0; // Count layout rows
label = new QLabel(tr("Name"));
label->setAlignment(Qt::AlignRight);
layout.addWidget(label, row, 0);
QLineEdit name(btn->text());
name.setToolTip(tr("Button caption"));
layout.addWidget(&name, row++, 1);
layout.setColumnStretch(1, 1);
label = new QLabel(tr("Tip"));
label->setAlignment(Qt::AlignRight);
layout.addWidget(label, row, 0);
QLineEdit tip(btn->toolTip());
tip.setToolTip(tr("Button tool tip"));
tip.setCursorPosition(0);
layout.addWidget(&tip, row++, 1, 1, 2);
layout.setColumnStretch(2, 3);
label = new QLabel(tr("Command"));
label->setAlignment(Qt::AlignRight);
layout.addWidget(label, row, 0);
QLineEdit command(mCommands.at(id));
//QTextEdit command(mCommands.at(id));
command.setCursorPosition(0);
command.setToolTip(tr("Available Tags are: %1").arg("[Provider] [Symbol] [Market] "
"[FiId] [MarketId]"));
layout.addWidget(&command, row++, 1, 1, 2); // Spawn over two colums...
// layout.setColumnStretch(2, 2); // ...and take more space
label = new QLabel(tr("Symbol Type"));
label->setAlignment(Qt::AlignRight);
layout.addWidget(label, row, 0);
// QLineEdit symbolType(mSymbolTypes.at(id));
QComboBox symbolType;
symbolType.setToolTip(tr("Witch type has to be [Symbol]. When empty is called once with any symbol\n"
"(You should not use [Symbol] in this case at the command)"));
SymbolTypeTuple* st = mFilu->getSymbolTypes(Filu::eAllTypes);
if(st)
{
while(st->next()) symbolType.addItem(st->caption());
}
symbolType.addItem("");
symbolType.setCurrentIndex(symbolType.findText(mSymbolTypes.at(id)));
layout.addWidget(&symbolType, row, 1);
QCheckBox allMarkets(tr("All Markets"));
allMarkets.setToolTip(tr("Call multiple times with all markets by 'Symbol Type'"));
allMarkets.setChecked(mMultis.at(id));
layout.addWidget(&allMarkets, row++, 2);
// Add an empty row to take unused space
layout.addWidget(new QWidget, row, 1);
layout.setRowStretch(row++, 2);
// Build the button line
QDialogButtonBox dlgBtns(QDialogButtonBox::Save | QDialogButtonBox::Discard);
QPushButton* db = dlgBtns.button(QDialogButtonBox::Discard);
dlgBtns.addButton(db, QDialogButtonBox::RejectRole);
connect(&dlgBtns, SIGNAL(accepted()), &dialog, SLOT(accept()));
connect(&dlgBtns, SIGNAL(rejected()), &dialog, SLOT(reject()));
DialogButton* remove = new DialogButton(tr("&Remove"), -1);
remove->setToolTip(tr("Remove button"));
dlgBtns.addButton(remove, QDialogButtonBox::ActionRole);
connect(remove, SIGNAL(clicked(int)), &dialog, SLOT(done(int)));
DialogButton* add = new DialogButton(tr("&Add"), 2);
add->setToolTip(tr("Copy to new button"));
dlgBtns.addButton(add, QDialogButtonBox::ActionRole);
connect(add, SIGNAL(clicked(int)), &dialog, SLOT(done(int)));
layout.addWidget(&dlgBtns, row, 1, 1, 2);
dialog.setWindowTitle(tr("LaunchPad - Edit button '%1'").arg(btn->text()));
dialog.setMinimumWidth(350);
switch (dialog.exec())
{
case 0: // Discard
return;
break;
case -1: // Remove
{
int ret = QMessageBox::warning(&dialog
, tr("LaunchPad - Last chance to keep your data")
, tr("Are you sure to delete button <b>'%1'</b> with all your work<b>?</b>")
.arg(btn->text())
, QMessageBox::Yes | QMessageBox::No
, QMessageBox::No);
//.........这里部分代码省略.........
示例5: setStandardKeys
void shortcuts::setStandardKeys(QWidget* widget)
{
if (!widget)
return;
// Add standard shortcuts to applicable buttons
bool hasShortcut = false;
QPushButton* button;
// For Save
button = widget->findChild<QPushButton*>("_save");
if (button)
{
button->setShortcut(QKeySequence::Save);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
hasShortcut = true;
}
if (!hasShortcut) // Because some screens have both
{
// For Post
button = widget->findChild<QPushButton*>("_post");
if (button)
{
button->setShortcut(QKeySequence::Save);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
}
}
if (!hasShortcut)
{
QDialogButtonBox* bb = widget->findChild<QDialogButtonBox*>();
if (bb)
{
QList<QAbstractButton*> buttons = bb->buttons();
for (int i = 0; i < buttons.size(); ++i)
{
QAbstractButton *bbutton = buttons.at(i);
QDialogButtonBox::ButtonRole btnrole = bb->buttonRole(buttons.at(i));
if (btnrole == QDialogButtonBox::AcceptRole)
{
bbutton->setShortcut(QKeySequence::Save);
bbutton->setToolTip(bbutton->text().remove("&") + " " +
bbutton->shortcut().toString(QKeySequence::NativeText));
}
else if (btnrole == QDialogButtonBox::RejectRole)
{
bbutton->setShortcut(QKeySequence::Close);
bbutton->setToolTip(bbutton->text().remove("&") + " " +
bbutton->shortcut().toString(QKeySequence::NativeText));
}
}
}
}
// For Close
hasShortcut = false;
button = widget->findChild<QPushButton*>("_close");
if (button)
{
button->setShortcut(QKeySequence::Close);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
hasShortcut = true;
}
if (!hasShortcut) // Because some screens have both
{
// For Post
button = widget->findChild<QPushButton*>("_cancel");
if (button)
{
button->setShortcut(QKeySequence::Close);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
}
}
// For New
button = widget->findChild<QPushButton*>("_new");
if (button)
{
button->setShortcut(QKeySequence::New);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
hasShortcut = true;
}
// For Print
button = widget->findChild<QPushButton*>("_print");
if (button)
{
button->setShortcut(QKeySequence::Print);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
hasShortcut = true;
}
// For Query
//.........这里部分代码省略.........
示例6: QWidget
DriverWidget::DriverWidget(const Device &device, QWidget *parent)
: QWidget(parent)
, ui(new Ui::Form)
, m_radioGroup(new QButtonGroup(this))
{
ui->setupUi(this);
ui->label->setText(xi18nc("@info %1 is hardware vendor, %2 is hardware model",
"<title>%1 %2</title>",
device.vendor,
device.model));
// We want to sort drivers so they have consistent order across starts.
QList<Driver> driverList = device.drivers;
qSort(driverList);
foreach (const Driver &driver, driverList) {
// This driver is not manual, but also has no package, hence we cannot
// do anything with it and should not display anything.
if (driver.package == nullptr && !driver.manualInstall){
qDebug() << "encountered invalid driver" << driver.package << driver.manualInstall << "for" << device.model;
continue;
}
QAbstractButton *button;
if (driverList.count() <= 1) {
button = new QCheckBox(this);
m_radioGroup->setExclusive(false);
} else {
button = new QRadioButton(this);
}
button->setProperty("package", driver.packageName);
button->setProperty("builtin", driver.builtin);
ui->verticalLayout->addWidget(button);
m_radioGroup->addButton(button);
if (driver.fuzzyActive) {
button->setChecked(true);
}
if (driver.manualInstall) {
button->setText(i18nc("Manually installed 3rd party driver",
"This device is using a manually-installed driver : (%1)",
driver.packageName));
break; // Manually installed drivers have no additional information available.
}
if (driver.recommended) {
button->setText(i18nc("%1 is description and %2 is package name; when driver is recommended for use",
"Using %1 from %2 (Recommended Driver)",
driver.package->shortDescription(),
driver.package->name()));
} else { // !recommended
button->setText(i18nc("%1 is description and %2 is package name",
"Using %1 from %2",
driver.package->shortDescription(),
driver.package->name()));
}
if (driver.free) {
button->setToolTip(i18nc("The driver is under a open source license",
"Open Source Driver"));
} else { // !free
button->setToolTip(i18nc("The driver is under a proprietary license",
"Proprietary Driver"));
}
}
m_indexSelected = m_radioGroup->checkedId();
m_defaultSelection = m_indexSelected;
connect(m_radioGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(selectionChanged()));
}