当前位置: 首页>>代码示例>>C++>>正文


C++ QDockWidget::setFocusProxy方法代码示例

本文整理汇总了C++中QDockWidget::setFocusProxy方法的典型用法代码示例。如果您正苦于以下问题:C++ QDockWidget::setFocusProxy方法的具体用法?C++ QDockWidget::setFocusProxy怎么用?C++ QDockWidget::setFocusProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDockWidget的用法示例。


在下文中一共展示了QDockWidget::setFocusProxy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createHeader

void MainWindow::createHeader()
{
//    QToolBar *tb = new QToolBar(this);
    QDockWidget *header = new QDockWidget(this);
    QHBoxLayout *ly = new QHBoxLayout();
    QFrame *frm = new QFrame();
    QPushButton *pbExit = new QPushButton();
    pbExit->setIcon(QIcon(":/images/meiti-up.png"));
    pbExit->setIconSize(QSize(40,40));

    pbExit->setFocusPolicy(Qt::NoFocus);
    pbExit->setFocusProxy(0);
    pbExit->setStyleSheet(QString("background-image: url(:/images/meiti-up.png);\n\n#pbExit:pressed {background-image: url(:/images/meiti-down.png) 4 4 4 4 strech strech;}\n\n#pbExit:hover {background-image: url(:/images/meiti-over.png) 4 4 4 4 strech strech;}\n"));

    connect(pbExit, SIGNAL(clicked()), qApp, SLOT(quit()));


    ly->addWidget(pbExit);
    ly->setAlignment(pbExit,Qt::AlignCenter);
    frm->setLayout(ly);
    frm->setAttribute(Qt::WA_TranslucentBackground, true);        // 设置背景透明(version >= QT4.5

    header->setWidget(frm);

    header->setAttribute(Qt::WA_TranslucentBackground, true);        // 设置背景透明(version >= QT4.5

    //header->setWindowFlags(Qt::FramelessWindowHint);
    header->setWindowTitle(QString(""));
    header->setTitleBarWidget(new QWidget);
    header->setFocusPolicy(Qt::NoFocus);
    header->setFocusProxy(0);
    header->setFeatures(QDockWidget::NoDockWidgetFeatures);
    header->setBaseSize(0,40);

    addDockWidget(Qt::TopDockWidgetArea,header, Qt::Horizontal);

//    tb->addWidget(frm);
//    pbExit->setText(QString("%1--%2--%3").arg(this->width()).arg(tb->width()).arg(pbExit->width()));
//
//    tb->setMovable(false);
//
//    this->addToolBar(tb);

//	dockWidget->setWidget(keyboardfrm);
//	dockWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
//	dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
//	addDockWidget(Qt::BottomDockWidgetArea,dockWidget);
}
开发者ID:ghl800,项目名称:hipibrowser,代码行数:48,代码来源:mainwindow.cpp

示例2: QDockWidget

QDockWidget *TikzCommandInserter::getDockWidget(QWidget *parent)
{
	QDockWidget *tikzDock = new QDockWidget(parent);
	tikzDock->setObjectName("CommandsDock");
	tikzDock->setAllowedAreas(Qt::AllDockWidgetAreas);
	tikzDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
	tikzDock->setWindowTitle(m_tikzSections.title);
	tikzDock->setWhatsThis(tr("<p>This is a list of TikZ "
	                          "commands.  You can insert these commands in your code by "
	                          "clicking on them.  You can obtain more commands by "
	                          "changing the category in the combo box.</p>"));

	QAction *focusTikzDockAction = new QAction(parent);
	focusTikzDockAction->setShortcut(QKeySequence(tr("Alt+I")));
	tikzDock->addAction(focusTikzDockAction);
	connect(focusTikzDockAction, SIGNAL(triggered()), tikzDock, SLOT(setFocus()));

	QLabel *commandsComboLabel = new QLabel(tr("Category:"));
	ComboBox *commandsCombo = new ComboBox;
	commandsCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
	QStackedWidget *commandsStack = new QStackedWidget;
	connect(commandsCombo, SIGNAL(currentIndexChanged(int)), commandsStack, SLOT(setCurrentIndex(int)));

	QListWidget *tikzListWidget = new QListWidget;
	addListWidgetItems(tikzListWidget, m_tikzSections, false); // don't add children
	tikzListWidget->setMouseTracking(true);
	connect(tikzListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
	connect(tikzListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
	connect(tikzListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
//	connect(tikzListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
	commandsCombo->addItem(tr("General"));
	commandsStack->addWidget(tikzListWidget);

	for (int i = 0; i < m_tikzSections.children.size(); ++i)
	{
		QListWidget *tikzListWidget = new QListWidget;
		addListWidgetItems(tikzListWidget, m_tikzSections.children.at(i));
		tikzListWidget->setMouseTracking(true);
		connect(tikzListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
		connect(tikzListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
		connect(tikzListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
//		connect(tikzListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));

		QString comboItemText = m_tikzSections.children.at(i).title;
		commandsCombo->addItem(comboItemText.remove('&'));
		commandsStack->addWidget(tikzListWidget);
	}

	QGridLayout *tikzLayout = new QGridLayout;
	tikzLayout->addWidget(commandsComboLabel, 0, 0);
	tikzLayout->addWidget(commandsCombo, 0, 1);
	tikzLayout->addWidget(commandsStack, 1, 0, 1, 2);
	tikzLayout->setMargin(5);

	TikzCommandWidget *tikzWidget = new TikzCommandWidget;
	tikzWidget->setLayout(tikzLayout);
	tikzDock->setWidget(tikzWidget);
	tikzDock->setFocusProxy(commandsCombo);

	return tikzDock;
}
开发者ID:KarateSnowMachine,项目名称:qtikz-svn,代码行数:61,代码来源:tikzcommandinserter.cpp


注:本文中的QDockWidget::setFocusProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。