qt-interest@trolltech.com
[Top] [All Lists]

Re: Subclassing

Subject: Re: Subclassing
From: Oleg Malashenko
Date: Tue, 15 Mar 2005 23:10:40 +0300
On Mon, 14 Mar 2005 16:35:47 -0700, Christopher Thompson 
<chris@xxxxxxxxxxxxxxxxx> wrote:

> On March 14, 2005 01:34 pm, Oleg Malashenko wrote:
>> Hello, All.
[skipped]
>
> No, subclass QWidget and instantiate a QLineEdit and a QPushButton inside 
> of it, in a layout.
>
> Or just use Qt Designer to do this.
>
Maybe I'm telling not clear enough, so sorry for my english.

I want to create a plugin. In that plugin I want to have widget 
(MyLineEdit) with such properties:
1. It acts absolutely like QLineEdit
2. In the right of that widget there is a button (see pic.1 in my 1st 
letter)
3. There is protected slot, that process button clicked() signal.

If I subclass QWidget, I'll have to provide interface to QLineEdit.
Next, if I provide such interface, I'll have to do the same up the class 
hierarchy. Not very comfortable, isn't it? So, I try to subclass QLineEdit.
All that I get is picture 2 in my 1st letter.

Logically, I found that solution with subclassing QLineEdit. Next steps are 
done in
MyLineEdit constructor:
1. create base class QLineEdit
2. create QWidget w on parent
3. create QHBoxLayout l on w
4. reparent() this to w
5. create QPushButton b on w
6. insert both this and b into layout l

What do you say? I this a way?

P.S: I still can't make this method work :)

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

--
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>