c++ - Use custom tab bar with QMdiArea -
i see qmdiarea
has tabbed view mode. want able split main window 2 qmdiarea
widgets , able drag , drop tabs between each of them. have done simple qtabwidget
can set custom tab bar. @ same time want switch qmdiarea
view mode using qtabwidget
not option me. don't see methods set custom tab bar within qmdiarea
. still have hope done. can suggest something?
tested solution qt 4.8 (edit)
after time of research can suggest following solution. have make new class inheriting qmdiarea
. set view mode tabbedview
make standart qtabbar
constructed within qmdiarea
. children , find qtabbar
widget qstring(qobject::metaobject()->classname()) == "qtabbar"
. hide it. blank area above document in tabbedview
mode. construct custom tab bar , reparent custom mdi area. connect signals , slots fired , used when sub windows , tabs activated. can have custom tab bar class member of custom mdi area.
if have found post useful please vote on it. thanks.
some code example.
looking standart
qtabbar
within custom mdi area in constructor:m_pmdiareatabbar = null; m_pmdiarea->setviewmode(qmdiarea::tabbedview); qobjectlist listchildren = m_pmdiarea->children(); (qobjectlist::iterator = listchildren.begin(); != listchildren.end(); ++i) { if (qstring((*i)->metaobject()->classname()) == "qtabbar") { m_pmdiareatabbar = dynamic_cast<qtabbar*>(*i); break; } }
reparent:
m_ptabbar->setparent(m_pmdiarea);
hiding:
if (m_pmdiareatabbar != 0) m_pmdiareatabbar->hide();
signals & slots used:
qmdiarea::subwindowactivated(qmdisubwindow*)
,qtabbar::currentchanged(int)
Comments
Post a Comment