[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [Fwd: 2 problems while developing for KDE]
From:       Michael Goffioul <goffioul () imec ! be>
Date:       2001-03-06 17:27:42
[Download RAW message or body]

> > I don't install anything, the word "cleanupEventFilter" doesn't appear at
> > all in my code, that's why it's strange to get this error. Anyway adding the
> > Q_OBJECT macro solves the problem.
>
> Nothing strange there. If you inherit QObject, you have to use Q_OBJECT
> otherwise the slots (from QObject itself) can't be accessed by Qt.

OK, I didn't know I had to use the Q_OBJECT macro in all the hierarchical
class tree (at least those branches that defines new signals/slots).

> > I know that. The fact is that I wrote a widget for a specific task: it inherits
> > KMainWIndow, defines actions and a toolbar. And I'd like to use this widget
> > as is either in a standalone application, or in a tab widget in another application.
> > On the first hand, it would be stupid to write twice the same functionalities,
> > and on the other hand, it would be sad not being able to use all the features
> > of the KMainWindow class and having to recode stuffs related to actions and
> > toolbars.
> The proper solution for this would be to move all this functionality into a
> separate class, used by KMainWindow (which inherits QMainWindow, so
> it's definitely standalone) and by your embeddable widget......
> Except that you giving toolbars to something that isn't a QMainWindow isn't
> as easy (although possible, see kfiledialog). I guess this becomes a Qt question
> from there.

That's what I did for another widget where I needed a toolbar (but wasn't involved
in standalone app). I just created a toolbar and inserted my widget and toolbar
into a layout. The QToolBar class doens't like it much, but it only pops up a
warning.

> > What's strange is that it works OK as long as you don't insert the KMainWindow
> > directly into a layout.
> Did you try reparent'ing the mainwindow ?

Schematically, this works:

    QTabWidget    *tab = new QTabWidget(...);
    KMainWindow    *w = new KMainWindow(tab);
    tab->addTab(w,"text");

This doesn't work:

    QTabWidget    *tab = new QTabWidget(...);
    QWidget        *widget = new QWidget(tab);
    KMainWindow    *w = new KMainWindow(widget);
    QVBoxLayout    *lay = new QVBoxLayout(widget, 10, 0);
    lay->addWidget(w,1);

In the second case, the KMainWindow is not shown, and if I force a "show",
then it is shown as separate window.
(Note: this is not compilable code, this is just to make things clearer)

Michael.


--
------------------------------------------------------------------
Michael Goffioul                IMEC-DESICS-MIRA
e-mail: goffioul@imec.be        (Mixed-Signal and RF Applications)
Tel:    +32/16/28-8510          Kapeldreef, 75
Fax:    +32/16/28-1515          3001 HEVERLEE, BELGIUM
------------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic