refs #634, find parent tab widget

This commit is contained in:
Klaus Basan
2016-04-02 18:57:43 +02:00
parent 70aacf8cb1
commit 4b621bcb1a
2 changed files with 18 additions and 0 deletions

View File

@@ -247,6 +247,21 @@ namespace BlackGui
return Qt::WindowStaysOnTopHint & flags;
}
QTabWidget *CGuiUtility::parentTabWidget(QWidget *widget, int maxLevels)
{
int level = 0;
do
{
widget = widget->parentWidget();
if (!widget) { return nullptr; }
QTabWidget *tw = qobject_cast<QTabWidget *>(widget);
if (tw) { return tw; }
level++;
}
while (level < maxLevels);
return nullptr;
}
bool CGuiUtility::toggleStayOnTop(QWidget *widget)
{
if (!widget) { return false; }

View File

@@ -77,6 +77,9 @@ namespace BlackGui
//! Window on top?
static bool staysOnTop(QWidget *widget);
//! From a given widget try to find parent tab widget (where widget is embedded)
static QTabWidget *parentTabWidget(QWidget *widget, int maxLevels = 5);
private:
//! Constructor, use static methods only
CGuiUtility() {}