Skip to content

Commit e6e83d5

Browse files
Added test for CDockWidget::setWindowTitle function
1 parent 0d24229 commit e6e83d5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

demo/MainWindow.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ struct MainWindowPrivate
165165
QWidgetAction* PerspectiveListAction = nullptr;
166166
QComboBox* PerspectiveComboBox = nullptr;
167167
ads::CDockManager* DockManager = nullptr;
168+
ads::CDockWidget* WindowTitleTestDockWidget = nullptr;
168169

169170
MainWindowPrivate(CMainWindow* _public) : _this(_public) {}
170171

@@ -382,6 +383,7 @@ void MainWindowPrivate::createContent()
382383
}
383384

384385
DockWidget = createLongTextLabelDockWidget();
386+
WindowTitleTestDockWidget = DockWidget;
385387
DockWidget->setFeature(ads::CDockWidget::DockWidgetFocusable, false);
386388
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
387389
auto FileSystemWidget = createFileSystemTreeDockWidget();
@@ -496,6 +498,9 @@ void MainWindowPrivate::createActions()
496498
ui.menuTests->addSeparator();
497499
a = ui.menuTests->addAction("Show Status Dialog");
498500
_this->connect(a, SIGNAL(triggered()), SLOT(showStatusDialog()));
501+
502+
a = ui.menuTests->addAction("Toggle Label 0 Window Title");
503+
_this->connect(a, SIGNAL(triggered()), SLOT(toggleDockWidgetWindowTitle()));
499504
ui.menuTests->addSeparator();
500505
}
501506

@@ -745,3 +750,20 @@ void CMainWindow::showStatusDialog()
745750
Dialog.exec();
746751
}
747752

753+
754+
//============================================================================
755+
void CMainWindow::toggleDockWidgetWindowTitle()
756+
{
757+
QString Title = d->WindowTitleTestDockWidget->windowTitle();
758+
int i = Title.indexOf(" (Test)");
759+
if (-1 == i)
760+
{
761+
Title += " (Test)";
762+
}
763+
else
764+
{
765+
Title = Title.left(i);
766+
}
767+
d->WindowTitleTestDockWidget->setWindowTitle(Title);
768+
}
769+

demo/MainWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ private slots:
6464
void createTable();
6565
void onEditorCloseRequested();
6666
void showStatusDialog();
67+
void toggleDockWidgetWindowTitle();
6768
};
6869

6970
#endif // MAINWINDOW_H

0 commit comments

Comments
 (0)