Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, July 2004
Plugin help


Message 1 in thread

Hello All!

I am new to plugin writing in Qt.  I compiled the example plugins are they 
are working properly.  I would like to write a small qt plugin with  a 
main window and a label saying Hello in it.

I get the following errors.
--------------------------------------------------------------------------
example.cpp: In member function `QObject* ExampleInstance::qObject()':
example.cpp:39: `QObject' is an ambiguous base of `ExampleInstance'
example.cpp: In member function `virtual void
    Example::mouseReleaseEvent(QMouseEvent*)':
example.cpp:20: warning: unused parameter `QMouseEvent*event'
make: *** [example.o] Error 1
--------------------------------------------------------------------------

The code is given here.  example.h is given after example.cpp

example.cpp
--------------------------------------------------------------------------
// Qt stuff
#include "/usr/local/qt/extensions/nsplugin/src/qnp.h"
#include <qpainter.h>
#include <qmessagebox.h>
#include "example.h"



class Example : public QNPWidget{
     Q_OBJECT

public:
     Example()
   {

     QMessageBox::message("Help", "No help for this data");
   }

     void mouseReleaseEvent(QMouseEvent* event)
     {
       QMessageBox::aboutQt(this);
     }

     void paintEvent(QPaintEvent* event)
     {
      	QPainter p(this);
 	p.setClipRect(event->rect());
 	int w = width();
 	p.drawRect(rect());
 	p.drawText(w/8, 0, w-w/4, height(), AlignCenter|WordBreak, 
"Example!");
 	   QMessageBox::message("Help", "No help for this data");



     }
};

class ExampleInstance : public QNPInstance, Form1 {
     Q_OBJECT
public:
     QLabel *label;
   QWidget *win;
     ExampleInstance()
   {
       win =  new QWidget(0);
       label = new QLabel("Hello",win);
       label->setText("Hello");

   }
     QNPWidget* newWindow()
     {
       /*QWidget *win =  new QWidget(0);
       label = new QLabel(win);
       label.setText("Hello");*/
       label->show();
       return new Example;
     }

     void print(QPainter* p)
     {
 	p->drawText(0,0,"Hello");
     }


};

class ExamplePlugin : public QNPlugin {
public:
     QNPInstance* newInstance()
     {
 	return new ExampleInstance;
     }

     const char* getMIMEDescription() const
     {
 	return "example/very:xxx:Example and useless";
     }

     const char * getPluginNameString() const
     {
 	return "Example Qt-based Plugin";
     }

     const char * getPluginDescriptionString() const
     {
 	return "A Qt-based LiveConnected plug-in that does nothing";
     }

};

QNPlugin* QNPlugin::create()
{
     return new ExamplePlugin;
}

#include "example.moc"

--------------------------------------------------------------------------


example.h
--------------------------------------------------------------------------
#ifndef FORM1_H
#define FORM1_H
#endif

#include <qvariant.h>
#include <qdialog.h>
#include<qscrollview.h>
#include <qpushbutton.h>
#include <qlabel.h>

class QVBox;
class QHBox;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QGrid;
class QProcess;
class QLabel;

class Form1 : public QScrollView
{
   //    Q_OBJECT

  public:
     Form1( QWidget* parent = 0);
     ~Form1();

};
-------------------------------------------------------------------------


Have a nice day!

Regards,

Hems.

--
 [ signature omitted ] 

Message 2 in thread

N Hemalatha wrote:

> Hello All!
>
> I am new to plugin writing in Qt.  I compiled the example plugins are 
> they are working properly.  I would like to write a small qt plugin 
> with  a main window and a label saying Hello in it.
>
> I get the following errors.
> -------------------------------------------------------------------------- 
>
> example.cpp: In member function `QObject* ExampleInstance::qObject()':
> example.cpp:39: `QObject' is an ambiguous base of `ExampleInstance'
> example.cpp: In member function `virtual void
>    Example::mouseReleaseEvent(QMouseEvent*)':
> example.cpp:20: warning: unused parameter `QMouseEvent*event'
> make: *** [example.o] Error 1
> -------------------------------------------------------------------------- 
>
>

The problem is in the multiple inheritance from ExampleInstance. If you 
draw the ExampleInstance inheritance graph, you will see you get a 
diamond, that is, ExampleInstance inherits QObject two times. I am not 
sure how to solve it, but at least I point out the problem.

jordi

>
>


Message 3 in thread

Thank you.  I got the problem, just today morning.

I have another doubt.  I am writing a plugin in Qt.  It will be like a 
full application embedded as a plugin.  I would like to know the procedure 
for getting key board i/p.  Actually, Qt web page says that keyboard input 
works on only the secondary windows created by plugin.  Can anyone show me 
an example  or any idea about it?

I would be very glad to know if anyone has implemented a qt plugin with 
keyboard i/p from user.

Thanks in advance.

Have a nice day!

Regards,

Hems.

--
 [ signature omitted ] 

Message 4 in thread

Hello All!

I am writing a plugin in Qt.  I would like to display a window(derived 
from QMainWindow) on clicking a button.  If I do so, Mozilla is not 
recognising my plugin though compilation goes without errors.

But if I use QMainWindow object directly, it works well.  Can anyone tell 
me the reason?

If I am not clear, kindly let me know.  Thanks in advance.

Have a nice day!

Regards,

Hems.

--
 [ signature omitted ] 

Message 5 in thread

Hai All!

> Your question is not clear. Where did mozilla come in when creating QT
> plugins. Are you getting the control under the tools group ? Is the QT
> designer recognizing the control first ?
>
> Delineate.

Thanks for asking for more details.
Actually I am writing plugin in Qt for Mozilla.  General procedure is:

1. Write a plugin using Qt.
2. Compile as .so file (so - shared object).
3. Copy the .so file to your browser's plugin directory.
4. Write a html page to embed that plugin.
5. Open the html page in Mozilla or the browser in whose's plugin 
directory you have copied the plugin.
6. The qt program i.e what you created in the plugin program will be 
appear in the browser as per the embed tag.
7. If the browser doesn't recognise or register your plugin, then you will 
see a small icon, on clicking it it will say that the appropriate plugin 
isn't found.

Now, if you read the following I think it will be ok.


>> I am writing a plugin in Qt.  I would like to display a window(derived
>> from QMainWindow) on clicking a button.  If I do so, Mozilla is not
>> recognising my plugin though compilation goes without errors.
>>
>> But if I use QMainWindow object directly, it works well.  Can anyone tell
>> me the reason?
>>
>> If I am not clear, kindly let me know.  Thanks in advance.
>>
>> Have a nice day!
>>
>> Regards,
>>
>> Hems.
>>
>> --
>> N Hemalatha, LLI - DON Lab Phone: 2257-8353
>> IIT Madras, Chennai-36. hemalatha@lantana.tenet.res.in
>>


Message 6 in thread

Hai All!

I am writing a plugin in Qt.  I want to instantiate a class derived from 
QMainWindow as the plugin window.  But when I included the needed header 
files, the compiling went on well.  The plugin is also properly 
registered with the browser.

But, on opening a HTML page containing that plugin, the correct window is 
displayed for a second & then closes automatically.  Mozilla also doesn't
report any errors.

Can anyone help me?  Let me know if anyone has written any plugin apart 
from Qt examples.

Have a nice day!

Regards,

Hems.