本文整理汇总了C++中QToolBar::setFocusPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolBar::setFocusPolicy方法的具体用法?C++ QToolBar::setFocusPolicy怎么用?C++ QToolBar::setFocusPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolBar
的用法示例。
在下文中一共展示了QToolBar::setFocusPolicy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QPushButton
Test4Window::Test4Window(const QString &sql)
: Ui::Test4Window()
{
Ui::Test4Window::setupUi(this);
QToolBar *toolBar = QMainWindow::addToolBar("TB");
toolBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
toolBar->setFocusPolicy(Qt::NoFocus);
pushButton = new QPushButton("Oracle", toolBar);
pushButton->setFlat(true);
toolBar->addWidget(pushButton);
connect(pushButton, SIGNAL(released()), this, SLOT(setLexer()));
QAction *oracle = new QAction("Oracle", this);
QAction *mysql = new QAction("MySQL", this);
oracle->setCheckable(true);
oracle->setChecked(true);
mysql->setCheckable(true);
mysql->setChecked(false);
QActionGroup* group = new QActionGroup(this);
oracle->setActionGroup(group);
mysql->setActionGroup(group);
menuGrammar->addAction(oracle);
menuGrammar->addAction(mysql);
editorLeft = new toSqlText(this);
leftVerticalLayout->addWidget(editorLeft);
editorLeft->setText(sql);
editorLeft->enableToolTips();
editorRight = new toSqlText(this);
editorRight->setHighlighter(toSqlText::Oracle);
rightVerticalLayout->addWidget(editorRight);
editorRight->setText(sql);
editorRight->setMarginType(2, QsciScintilla::TextMarginRightJustified);
editorRight->setMarginWidth(2, QString::fromLatin1("009"));
editorRight->enableToolTips();
connect(oracle, SIGNAL(triggered()), this, SLOT(setOracle()));
connect(mysql, SIGNAL(triggered()), this, SLOT(setMySQL()));
connect(actionLoad, SIGNAL(triggered()), this, SLOT(load()));
connect(actionQuit, SIGNAL(triggered()), this, SLOT(close()));
QMainWindow::show();
}
示例2: catch
QToolBar *toAllocBar(QWidget *parent, const QString &str)
{
QString db;
try
{
db = toConnection::currentConnection(parent).description(false);
}
catch (QString const& e)
{
TLOG(1, toDecorator, __HERE__) << " Ignored exception: " << e << std::endl;
}
catch (...)
{
TLOG(1, toDecorator, __HERE__) << " Ignored exception." << std::endl;
}
QString name = str;
if (!db.isEmpty() && toConfigurationNewSingle::Instance().option(ToConfiguration::Global::IncludeDbCaptionBool).toBool())
{
name += QString::fromLatin1(" ");
name += db;
}
QToolBar *tool;
QMainWindow *main = dynamic_cast<QMainWindow *>(parent);
if (main)
tool = toMainWindow::lookup()->addToolBar(name);
else
tool = new QToolBar(parent);
// Enforce smaller toolbars on mac
tool->setIconSize(QSize(16, 16));
tool->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Fixed));
tool->setFocusPolicy(Qt::NoFocus);
return tool;
}
示例3: QMainWindow
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
{
const int screenWidth = QApplication::desktop()->width();
const int screenHeight = QApplication::desktop()->height();
const int appWidth = 500;
const int appHeight = 300;
setGeometry((screenWidth - appWidth) / 2, (screenHeight - appHeight) / 2, appWidth, appHeight);
setObjectName("mainwindow");
setWindowTitle("developers' test version, not for public use");
setWindowIcon(QIcon(":/icons/icon64.png"));
setContextMenuPolicy(Qt::PreventContextMenu);
QDockWidget* friendDock = new QDockWidget(this);
friendDock->setObjectName("FriendDock");
friendDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
friendDock->setTitleBarWidget(new QWidget(friendDock));
friendDock->setContextMenuPolicy(Qt::PreventContextMenu);
addDockWidget(Qt::LeftDockWidgetArea, friendDock);
QWidget* friendDockWidget = new QWidget(friendDock);
QVBoxLayout* layout = new QVBoxLayout(friendDockWidget);
layout->setMargin(0);
layout->setSpacing(0);
friendDock->setWidget(friendDockWidget);
ourUserItem = new OurUserItemWidget(this);
friendsWidget = new FriendsWidget(friendDockWidget);
// Create toolbar
QToolBar *toolBar = new QToolBar(this);
toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
toolBar->setIconSize(QSize(16, 16));
toolBar->setFocusPolicy(Qt::ClickFocus);
QToolButton *addFriendButton = new QToolButton(toolBar);
addFriendButton->setIcon(QIcon("://icons/user_add.png"));
addFriendButton->setToolTip(tr("Add friend"));
connect(addFriendButton, &QToolButton::clicked, friendsWidget, &FriendsWidget::onAddFriendButtonClicked);
QWidget *spacer = new QWidget(toolBar);
spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
QToolButton *menuButton = new QToolButton(toolBar);
menuButton->setIcon(QIcon("://icons/cog.png"));
menuButton->setToolTip(tr("Mainmenu"));
menuButton->setPopupMode(QToolButton::InstantPopup);
QMenu *mainmenu = new QMenu(menuButton);
mainmenu->addAction(QIcon(":/icons/setting_tools.png"), tr("Settings"), this, SLOT(onSettingsActionTriggered()));
mainmenu->addSeparator();
mainmenu->addAction(tr("About %1").arg(AppInfo::name), this, SLOT(onAboutAppActionTriggered()));
mainmenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()));
mainmenu->addSeparator();
mainmenu->addAction(tr("Quit"), this, SLOT(onQuitApplicationTriggered()), QKeySequence::Quit);
menuButton->setMenu(mainmenu);
toolBar->addWidget(addFriendButton);
toolBar->addWidget(spacer);
toolBar->addWidget(menuButton);
// Create toolbar end
layout->addWidget(ourUserItem);
layout->addWidget(friendsWidget);
layout->addWidget(toolBar);
PagesWidget* pages = new PagesWidget(this);
connect(friendsWidget, &FriendsWidget::friendAdded, pages, &PagesWidget::addPage);
connect(friendsWidget, &FriendsWidget::friendSelectionChanged, pages, &PagesWidget::activatePage);
connect(friendsWidget, &FriendsWidget::friendStatusChanged, pages, &PagesWidget::statusChanged);
//FIXME: start core in a separate function
//all connections to `core` should be done after its creation because it registers some types
core = new Core();
coreThread = new QThread(this);
core->moveToThread(coreThread);
connect(coreThread, &QThread::started, core, &Core::start);
qRegisterMetaType<Status>("Status");
connect(core, &Core::connected, this, &MainWindow::onConnected);
connect(core, &Core::disconnected, this, &MainWindow::onDisconnected);
connect(core, &Core::friendRequestRecieved, this, &MainWindow::onFriendRequestRecieved);
connect(core, SIGNAL(friendStatusChanged(int, Status)), friendsWidget, SLOT(setStatus(int, Status)));
connect(core, &Core::friendAddressGenerated, ourUserItem, &OurUserItemWidget::setFriendAddress);
connect(core, &Core::friendAdded, friendsWidget, &FriendsWidget::addFriend);
connect(core, &Core::friendMessageRecieved, pages, &PagesWidget::messageReceived);
connect(core, &Core::actionReceived, pages, &PagesWidget::actionReceived);
connect(core, &Core::friendUsernameChanged, friendsWidget, &FriendsWidget::setUsername);
connect(core, &Core::friendUsernameChanged, pages, &PagesWidget::usernameChanged);
connect(core, &Core::friendRemoved, friendsWidget, &FriendsWidget::removeFriend);
connect(core, &Core::friendRemoved, pages, &PagesWidget::removePage);
connect(core, &Core::failedToRemoveFriend, this, &MainWindow::onFailedToRemoveFriend);
connect(core, &Core::failedToAddFriend, this, &MainWindow::onFailedToAddFriend);
connect(core, &Core::messageSentResult, pages, &PagesWidget::messageSentResult);
connect(core, &Core::actionSentResult, pages, &PagesWidget::actionResult);
coreThread->start(/*QThread::IdlePriority*/);
//.........这里部分代码省略.........
示例4: entryPoint
/**
\param bcont
**/
int entryPoint ( BfBulmaFact *bcont )
{
BL_FUNC_DEBUG
g_selcanales = new BcCanalSeleccionarView ( bcont->company(), 0 );
g_selccostes = new BcCentroCosteSeleccionarView (bcont->company(), 0);
/// Inicializa el sistema de traducciones 'gettext'.
setlocale ( LC_ALL, "" );
blBindTextDomain ( "pluginbf_canalyccoste", g_confpr->value( CONF_DIR_TRADUCCION ).toLatin1().constData() );
g_pluginbf_canalyccoste = bcont;
QMenu *pPluginMenu = bcont->menuMaestro;
pPluginMenu->addSeparator();
BlAction *accionA = new BlAction ( _ ( "&Canal" ), 0 );
accionA->setStatusTip ( _ ( "Ver Canales" ) );
accionA->setWhatsThis ( _ ( "Ver Canales" ) );
accionA->setIcon ( QIcon ( QString::fromUtf8 ( ":/BulmaCont32x32/images/png/i_canales.xpm" ) ) );
accionA->setObjectName("mui_actionCanal");
pPluginMenu->addAction ( accionA );
BlAction *accionB = new BlAction ( _ ( "&Centros de Coste" ), 0 );
accionB->setStatusTip ( _ ( "Ver Centros de Coste" ) );
accionB->setWhatsThis ( _ ( "Ver Centros de Coste" ) );
accionB->setIcon ( QIcon ( QString::fromUtf8 ( ":/BulmaCont32x32/images/png/i_centroCoste.xpm" ) ) );
accionB->setObjectName("mui_actionCCoste");
pPluginMenu->addAction ( accionB );
/// Añadimos la nueva opción al menú principal del programa.
/// Usamos un toolBox especial para meter los botones de contabilidad.
QToolBar *toolCont = bcont->findChild<QToolBar *> ( "contabilidad" );
if ( !toolCont) {
toolCont = new QToolBar(bcont);
toolCont->setObjectName("contabilidad");
toolCont->setFocusPolicy(Qt::TabFocus);
toolCont->setOrientation(Qt::Horizontal);
toolCont->setIconSize(QSize(32, 32));
toolCont->setWindowTitle(N_("Contabilidad", 0));
toolCont->setToolTip(N_("Contabilidad", 0));
toolCont->setStatusTip(N_("Contabilidad", 0));
toolCont->setWhatsThis(N_("Contabilidad", 0));
toolCont->setAccessibleName(N_("Contabilidad", 0));
toolCont->setAccessibleDescription(N_("Contabilidad", 0));
bcont->addToolBar(Qt::TopToolBarArea, toolCont);
} // end if
toolCont->addAction(accionA);
toolCont->addAction(accionB);
// =================================================
/// Vamos a probar con un docwindow.
BlDockWidget *doc1 = new BlDockWidget ( _ ( "Selector de Canales" ), bcont );
doc1->setObjectName("mui_selcanales");
doc1->setFeatures ( QDockWidget::AllDockWidgetFeatures );
doc1->setGeometry ( 100, 100, 100, 500 );
doc1->resize ( 330, 250 );
bcont->addDockWidget ( Qt::RightDockWidgetArea, doc1 );
doc1->show();
doc1->setWidget ( g_selcanales );
// =================================================
/**
*
*
*
*
*/
// =================================================
/// Vamos a probar con un docwindow.
BlDockWidget *doc2 = new BlDockWidget ( _ ( "Selector de Centros de Coste" ), bcont );
doc2->setObjectName("mui_selcostes");
doc2->setFeatures ( QDockWidget::AllDockWidgetFeatures );
doc2->setGeometry ( 100, 100, 100, 500 );
doc2->resize ( 330, 250 );
bcont->addDockWidget ( Qt::RightDockWidgetArea, doc2 );
doc2->show();
doc2->setWidget ( g_selccostes );
return 0;
}