[Qt-creator] Core::EditorManagerPlaceHolder::current() method replacement in Qt Creator 3.0
Ziller Eike
Eike.Ziller at digia.com
Wed Mar 5 08:58:41 CET 2014
On Mar 4, 2014, at 4:03 PM, Xiaofeng Wu <djangowu at gmail.com> wrote:
> I try the method you told me. The code is like the following
> bool EditorTabsPlugin::eventFilter(QObject *obj, QEvent *event)
> {
> if (event->type() == QEvent::ParentChange) {
> Core::EditorManager* manager = Core::EditorManager::instance();
> Core::EditorManagerPlaceHolder* placeHolder =
> static_cast<Core::EditorManagerPlaceHolder*>(manager->parent());
> placeHolder->layout()->addWidget(bar);
> }
> return false;
> }
>
* Always check against the obj before filtering an event. Your class might not be the only one that installs an object to your event filter (could e.g. also happen in the baseclass)
* Always return BaseClass::eventFilter(obj, event) in the end, for events that you don’t filter out (by accepting and returning true)
* manager->parent() can be 0. In that case probably best do bar->hide(); bar->setParent(0). When you do that, you should explicitly bar->show() again if placeHolder is *not* 0.
* I don’t know out of my head if layout()->addWidget actually reparents the widget, you might need bar->setParent(placeHolder) in addition (that would explain the toplevel)
Br, Eike
> The result is that it creates another window and put the widget in it instead of placing the widget on top of the editor panel.
>
> Where is the problem?
>
>
> On Thu, Feb 20, 2014 at 9:21 AM, Ziller Eike <Eike.Ziller at digia.com> wrote:
>
> On Feb 20, 2014, at 2:37 PM, Xiaofeng Wu <djangowu at gmail.com> wrote:
>
> > Hi,
>
> Hi, please do not send the same email multiple times.
>
> > I only want the tabs to show up in the main window, so what you said is not a problem to me.
> >
> > I understand that I can "take EditorManager::instance(), install yourself as an event filter" so that if the instance()'s parent changes, my code will know that.
> > But, when it happens, what is the code look like if I want to add a QTabWidget on top of the editor panel?
>
> you get the parent of EditorManager::instance(), if that is not 0, it is the EditorManagerPlaceHolder instance like before.
>
> Br, Eike
>
> > On Wed, Feb 19, 2014 at 10:22 AM, Ziller Eike <Eike.Ziller at digia.com> wrote:
> > Hi,
> >
> > I suppose you could take EditorManager::instance(), install yourself as an event filter, and do whatever magic on ParentChange events.
> >
> > Note that both your old method, and anything based on the parent of EditorManager::instance(), does not work with additional editor windows (Window > Open in New Window).
> >
> > Br, Eike
> >
> > On Feb 19, 2014, at 3:25 PM, Xiaofeng Wu <djangowu at gmail.com> wrote:
> >
> > > I am developing a Qt Creator plugin. This plugin shows currently opened files as a QTabWidget on top of the editor pane. In Qt Creator 2.8, the code works like the following,
> > > Core::EditorManagerPlaceHolder* holder = Core::EditorManagerPlaceHolder::current();
> > > holder->layout()->addWidget(myTabWidget);
> > >
> > > Here is the screen shot for the plugin running in Qt Creator 2.8
> > >
> > > <1.png>
> > >
> > > However, in Qt Creator 3.0, the method Core::EditorManagerPlaceHolder::current() no longer exists. In this situation how am I able to put the QTabWidget on the top the editor window
> > > _______________________________________________
> > > Qt-creator mailing list
> > > Qt-creator at qt-project.org
> > > http://lists.qt-project.org/mailman/listinfo/qt-creator
> >
> > --
> > Eike Ziller, Senior Software Engineer - Digia, Qt
> >
> > Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
> > Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
> > Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
> >
> >
> > _______________________________________________
> > Qt-creator mailing list
> > Qt-creator at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/qt-creator
>
> --
> Eike Ziller, Senior Software Engineer - Digia, Qt
>
> Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
> Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
> Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
>
>
--
Eike Ziller, Senior Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the Qt-creator
mailing list