本文整理汇总了C++中QMenu::setFocusPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::setFocusPolicy方法的具体用法?C++ QMenu::setFocusPolicy怎么用?C++ QMenu::setFocusPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::setFocusPolicy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dial_customer
void MainWindow::dial_customer(const QPoint& pos)
{
QPoint globalPos = ui->tableCustomers->mapToGlobal(pos);
//myWidget->mapToGlobal(pos);
// for QAbstractScrollArea and derived classes you would use:
// QPoint globalPos = myWidget->viewport()->mapToGlobal(pos);
QMenu myMenu;
myMenu.setFocusPolicy(Qt::NoFocus);
myMenu.addAction(trUtf8("Κλήση πελάτη"));
// ...
QAction* selectedItem = myMenu.exec(globalPos);
QString phone;
if (selectedItem)
{
QSqlQuery query(db1);
QString c_id=customer_model->data(customer_model->index(ui->tableCustomers->currentIndex().row(),0)).toString();
query.exec("select phone from customers where id="+c_id);
query.next();
phone=query.value(0).toString();
dial(phone);
}
}
示例2: context_menu_full_calls
void MainWindow::context_menu_full_calls(const QPoint &pos)
{
QPoint globalPos = ui->tableAllCalls->mapToGlobal(pos);
QMenu myMenu;
myMenu.setFocusPolicy(Qt::NoFocus);
myMenu.addAction(trUtf8("Κλήση πελάτη"));
QAction* selectedItem = myMenu.exec(globalPos);
QString phone;
if (selectedItem)
{
QString src=full_calls_model->data(full_calls_model->index(ui->tableAllCalls->currentIndex().row(),1)).toString();
QString dst=full_calls_model->data(full_calls_model->index(ui->tableAllCalls->currentIndex().row(),2)).toString();
if (src.length()>dst.length())
phone=src;
else
phone=dst.mid(1,15);
dial(phone);
}
}
示例3: context_menu
void MainWindow::context_menu(const QPoint& pos)
{
// for most widgets
QPoint globalPos = ui->tableView->mapToGlobal(pos);
//myWidget->mapToGlobal(pos);
// for QAbstractScrollArea and derived classes you would use:
// QPoint globalPos = myWidget->viewport()->mapToGlobal(pos);
QMenu myMenu;
myMenu.setFocusPolicy(Qt::NoFocus);
myMenu.addAction(trUtf8("Συνέχιση εργασίας"));
myMenu.addAction(trUtf8("Kλήση πελάτη"));
// ...
QAction* selectedItem = myMenu.exec(globalPos);
if (selectedItem)
{
QSqlQuery query(db1);
QString t_id=tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),0)).toString();
query.exec("select t.cusid,t.placeid,t.projectid,t.comment from tasks t where id="+t_id);
query.next();
this->cusid=query.value(0).toString();
QString t_cusid=cusid=query.value(0).toString();
if(selectedItem->text()==trUtf8("Συνέχιση εργασίας"))
{
refresh_places();
refresh_projects();
ui->label_customer->setText(tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),1)).toString());
ui->textEdit->setPlainText(query.value(3).toString());
for (int i=0;i<ui->comboplace->count();++i)
{
ui->comboplace->setCurrentIndex(i);
if (places_model->data(places_model->index(ui->comboplace->currentIndex(),0))==query.value(1).toInt())
break;
}
for (int i=0;i<ui->comboproject->count();++i)
{
ui->comboproject->setCurrentIndex(i);
if (project_model->data(project_model->index(ui->comboproject->currentIndex(),0))==query.value(2).toInt())
break;
}
ui->pushHour->setEnabled(TRUE);
}
else
{
query.exec("select phone from customers where id="+t_cusid);
query.next();
QString phone=query.value(0).toString();
dial(phone);
}
}
return;
}