本文整理汇总了C++中QDockWidget::windowTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ QDockWidget::windowTitle方法的具体用法?C++ QDockWidget::windowTitle怎么用?C++ QDockWidget::windowTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDockWidget
的用法示例。
在下文中一共展示了QDockWidget::windowTitle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void KoDockWidgetTitleBar::paintEvent(QPaintEvent*)
{
QStylePainter p(this);
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
int fw = q->isFloating() ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q) : 0;
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
QStyleOptionDockWidgetV2 titleOpt;
titleOpt.initFrom(q);
QSize collapseButtonSize(0,0);
if (d->collapsable) {
collapseButtonSize = d->collapseButton->size();
}
QSize lockButtonSize(0,0);
if (d->lockable) {
lockButtonSize = d->lockButton->size();
}
titleOpt.rect = QRect(QPoint(fw + mw + collapseButtonSize.width() + lockButtonSize.width(), 0),
QSize(geometry().width() - (fw * 2) - mw - collapseButtonSize.width() - lockButtonSize.width(), geometry().height()));
titleOpt.title = q->windowTitle();
titleOpt.closable = hasFeature(q, QDockWidget::DockWidgetClosable);
titleOpt.floatable = hasFeature(q, QDockWidget::DockWidgetFloatable);
p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
}
示例2: _addDockWidgets
void MainWindow::_addDockWidgets()
{
if(!_updatePending)
return ;
for(size_t ii = 0 ; ii < _dockWidgets.size() ; ii++)
{
QWidget* widget = _dockWidgets[ii] ;
Q_ASSERT(widget) ;
if (widget->parent() != 0)
return;
QDockWidget* dockWidget = qobject_cast<QDockWidget*>(widget);
if(!dockWidget) {
dockWidget = new QDockWidget(this);
dockWidget->setWidget(widget);
}
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea; // = 0x1
// area values are 0x1, 0x2, 0x4, 0x8
while(!dockWidget->isAreaAllowed(area) && area <= 0x8)
area=(Qt::DockWidgetArea)((int)area<<1);
if (!(area&Qt::AllDockWidgetAreas)) {
qDebug("%s",tr("No usable DockArea found for %1, using left one.").arg(
dockWidget->windowTitle()).toAscii().constData());
area = Qt::LeftDockWidgetArea;
}
QMainWindow::addDockWidget(area, dockWidget);
Q_ASSERT(widget->parent() != 0);
Q_ASSERT(dockWidget->parent() != 0);
}
_updatePending = false ;
}
示例3: QWidget
TitleBar::TitleBar(QWidget *parent)
: QWidget(parent)
,bpress(false) ,but_press(false)
{
//titleTxt = title;
if(parent)
{
QDockWidget *w = static_cast<QDockWidget*>(parent);
titleTxt = w->windowTitle();
}
create_pixmap();
}
示例4: createDockWindows
void MainWindow::createDockWindows()
{
m_wInputMonitor = new FrameMonitor(this);
m_wInputMonitorDock = new QDockWidget(tr("Input monitor"), this);
m_wInputMonitorDock->setWidget(m_wInputMonitor);
m_wInputMonitorDock->setObjectName("inputMonitor");
addDockWidget(Qt::TopDockWidgetArea, m_wInputMonitorDock);
m_wCurveMonitor = new FrameMonitor(this);
m_wCurveMonitorDock = new QDockWidget(tr("Curve monitor"), this);
m_wCurveMonitorDock->setWidget(m_wCurveMonitor);
m_wCurveMonitorDock->setObjectName("curveMonitor");
addDockWidget(Qt::TopDockWidgetArea, m_wCurveMonitorDock);
m_wRenderPreview = new RenderPreview(m_project, this);
m_wRenderPreviewDock = new QDockWidget(tr("Render preview"), this);
m_wRenderPreviewDock->setWidget(m_wRenderPreview);
m_wRenderPreviewDock->setObjectName("renderPreview");
addDockWidget(Qt::TopDockWidgetArea, m_wRenderPreviewDock);
//TODO: replace by :
// ui->menuView->addAction(dock->toggleViewAction());
// http://ariya.ofilabs.com/2007/04/custom-toggle-action-for-qdockwidget.html
// Fill the view menu that allows (de)activating widgets
QObjectList windowChildren = children();
QDockWidget *w;
for (int i = 0; i < windowChildren.size(); i++) {
if ((w = dynamic_cast<QDockWidget*>(windowChildren.at(i))) != NULL) {
qDebug() << "Adding " << w->windowTitle() << " to the menu's widget list";
QAction *a = new QAction("&" + w->objectName(), this);
a->setCheckable(true);
connect(a, SIGNAL(toggled(bool)), w, SLOT(setVisible(bool)));
// This does not work since it is also emitted e.g. when the window is minimized
// (with «Show Desktop» on KDE4), therefore an event filter is required. (below.)
// Thanks ArGGu^^ for the tip!
connect(w, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool)));
//a->setChecked(true);
#if QT_VERSION <= QT_VERSION_CHECK(4, 2, 0)
// To uncheck the menu entry when the widget is closed via the (x)
w->installEventFilter(this);
#endif
ui->menuView->addAction(a);
m_widgetActions << a;
}
}
}
示例5: sizeHint
QSize KoDockWidgetTitleBar::sizeHint() const
{
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
// get size of buttons...
QSize closeSize(0, 0);
if (d->closeButton && d->closeButton->isVisible()) {
closeSize = d->closeButton->sizeHint();
}
QSize floatSize(0, 0);
if (d->floatButton && d->floatButton->isVisible()) {
floatSize = d->floatButton->sizeHint();
}
QSize hideSize(0, 0);
if (d->collapseButton && d->collapseButton->isVisible()) {
hideSize = d->collapseButton->sizeHint();
}
int buttonHeight = qMax(qMax(closeSize.height(), floatSize.height()), hideSize.height()) + 2;
int buttonWidth = closeSize.width() + floatSize.width() + hideSize.width();
int height = buttonHeight;
if (d->textVisibilityMode == FullTextAlwaysVisible) {
// get font size
QFontMetrics titleFontMetrics = q->fontMetrics();
int fontHeight = titleFontMetrics.lineSpacing() + 2 * mw;
height = qMax(height, fontHeight);
}
/*
* Calculate the width of title and add to the total width of the docker window when collapsed.
*/
const int titleWidth =
(d->textVisibilityMode == FullTextAlwaysVisible) ? (q->fontMetrics().width(q->windowTitle()) + 2*mw) :
0;
if (d->preCollapsedWidth > 0) {
return QSize(d->preCollapsedWidth, height);
}
else {
return QSize(buttonWidth /*+ height*/ + 2*mw + 2*fw + titleWidth, height);
}
}
示例6: QMainWindow
MainWindow::MainWindow(QString projectPath, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
m_progressDialog(NULL),
m_renderProgressDialog(NULL),
m_flowExaminer(NULL),
m_cs(this)
{
ui->setupUi(this);
restoreGeometry(m_settings.value("geometry").toByteArray());
restoreState(m_settings.value("windowState").toByteArray());
m_project = new Project_sV();
m_wCanvas = new Canvas(m_project, this);
setCentralWidget(m_wCanvas);
m_wInputMonitor = new FrameMonitor(this);
m_wInputMonitorDock = new QDockWidget(tr("Input monitor"), this);
m_wInputMonitorDock->setWidget(m_wInputMonitor);
m_wInputMonitorDock->setObjectName("inputMonitor");
addDockWidget(Qt::TopDockWidgetArea, m_wInputMonitorDock);
m_wCurveMonitor = new FrameMonitor(this);
m_wCurveMonitorDock = new QDockWidget(tr("Curve monitor"), this);
m_wCurveMonitorDock->setWidget(m_wCurveMonitor);
m_wCurveMonitorDock->setObjectName("curveMonitor");
addDockWidget(Qt::TopDockWidgetArea, m_wCurveMonitorDock);
m_wRenderPreview = new RenderPreview(m_project, this);
m_wRenderPreviewDock = new QDockWidget(tr("Render preview"), this);
m_wRenderPreviewDock->setWidget(m_wRenderPreview);
m_wRenderPreviewDock->setObjectName("renderPreview");
addDockWidget(Qt::TopDockWidgetArea, m_wRenderPreviewDock);
// Fill the view menu that allows (de)activating widgets
QObjectList windowChildren = children();
QDockWidget *w;
for (int i = 0; i < windowChildren.size(); i++) {
if ((w = dynamic_cast<QDockWidget*>(windowChildren.at(i))) != NULL) {
qDebug() << "Adding " << w->windowTitle() << " to the menu's widget list";
QAction *a = new QAction("&" + w->objectName(), this);
a->setCheckable(true);
bool b = true;
b &= connect(a, SIGNAL(toggled(bool)), w, SLOT(setVisible(bool)));
// This does not work since it is also emitted e.g. when the window is minimized
// (with «Show Desktop» on KDE4), therefore an event filter is required. (below.)
// Thanks ArGGu^^ for the tip!
// b &= connect(w, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool)));
Q_ASSERT(b);
a->setChecked(true);
// To uncheck the menu entry when the widget is closed via the (x)
w->installEventFilter(this);
ui->menuView->addAction(a);
m_widgetActions << a;
}
}