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

Qt-interest Archive, May 2007
Qt fails to customize Qt-made controls programmatically, but MFC can.


Message 1 in thread

Qt fails to customize ActiveQt controls programmatically, but MFC can 
customize Qt-made ActiveX controls.

The test is based on a Qt example at:
C:\Qt\4.3.0beta\examples\activeQt\wrapper
where a group ActiveX controls are created. I picked up one of them, 
QPushButton for test.

Evidence 1: QPushButton is insertable to PowerPoint.
Open PowerPoint 2003, from its menu: View -> Toolbars -> Control Toolbox 
-> Toolbar Options -> More Controls, select “QPushButton Class” drag to 
insert. (If “QPushButton Class” is not in the list, you need to register 
it first.)

Evidence 2: QPushButton is modifiable manually.
Mouse right click on the button, from a context menu choose properties.
Find “text” and input some text, it should appear on the button.

Evidence 3: QPushButton is NOT programmaticable in Qt.
Using dumpcpp to generate wrapper classes for both Powerpoint and 
wrapperax, and include them in you test project.
Start PowerPopint programmatically:
oPPTApp = new PowerPoint::Application();
oPPTApp->dynamicCall("SetVisible(Office::MsoTriState)", true);
PowerPoint::Presentations* presentations = oPPTApp->Presentations();
PowerPoint::Presentation* presentation = presentations->Add();

Then, insert the control as an OLE object, . . .but setText() does not 
work.
QString className = "wrapperax.QPushButton";
shape = shapes->AddOLEObject(100, 100, 512, 320, className, false);

// custimize the object
PowerPoint::OLEFormat* fmt = shape->OLEFormat();
wrapperaxLib::IQPushButton iobj(fmt->Object());
iobj.setText("This is a push button."); // Does not work ???

Evidence 4: QPushButton is programmaticable in MFC.
(Microsoft Foundation Classes in Visual C++)
Similar approach and similar codes. The Button has text on it.
oShape = oShapes.AddOLEObject(20, 20, 660, 500, "wrapperax.QPushButton",
"", 0, "", 0, "", 0);
//Get the object handler to custimize
OLEFormat fmt = oShape.GetOLEFormat();
IQPushButton iobj(fmt.GetObject());
// manipulate the object programmatically.
iobj.SetText("This is QPushButton text."); // This works!

If you need more details for testing, feel free to send me emails.

Question is on Evidence 3: why QPushButton is NOT programmaticable in Qt?

Best regards,

Lingfa


--
 [ signature omitted ] 

Message 2 in thread

did you notice that you used "SetText" in MFC and "setText" in Qt?

not that i know anything about ActiveX wrapping, but this looked odd.

Cheers,
Peter

> -----Ursprüngliche Nachricht-----
> Von: Lingfa Yang [mailto:lingfa@xxxxxxx]
> Gesendet: Montag, 7. Mai 2007 20:40
> An: Qt Interest
> Betreff: Qt fails to customize Qt-made controls programmatically, but MFC
> can.
> 
> Qt fails to customize ActiveQt controls programmatically, but MFC can
> customize Qt-made ActiveX controls.
...
> Evidence 3: QPushButton is NOT programmaticable in Qt.
> iobj.setText("This is a push button."); // Does not work ???
...
> Evidence 4: QPushButton is programmaticable in MFC.
> iobj.SetText("This is QPushButton text."); // This works!

--
 [ signature omitted ] 

Message 3 in thread

Peter Prade wrote:

>did you notice that you used "SetText" in MFC and "setText" in Qt?
>  
>
Yes. All MFC-style functions in convention start with capital letters.
You know Qt better than me,  I do not know, but I just follow, in Qt 
function names start with small letters.
Cheers,
Lingfa

>not that i know anything about ActiveX wrapping, but this looked odd.
>
>Cheers,
>Peter
>  
>

--
 [ signature omitted ] 

Message 4 in thread

> Evidence 3: QPushButton is NOT programmaticable in Qt.
> Using dumpcpp to generate wrapper classes for both Powerpoint and 
> wrapperax, and include them in you test project.
> Start PowerPopint programmatically:
> oPPTApp = new PowerPoint::Application();
> oPPTApp->dynamicCall("SetVisible(Office::MsoTriState)", true);
> PowerPoint::Presentations* presentations = oPPTApp->Presentations();
> PowerPoint::Presentation* presentation = presentations->Add();
>
> Then, insert the control as an OLE object, . . .but setText() does not 
> work.
> QString className = "wrapperax.QPushButton";
> shape = shapes->AddOLEObject(100, 100, 512, 320, className, false);
>
> // custimize the object
> PowerPoint::OLEFormat* fmt = shape->OLEFormat();
> wrapperaxLib::IQPushButton iobj(fmt->Object());
> iobj.setText("This is a push button."); // Does not work ???


What error message do you get for the last call?

Does QueryInterface'ing the interface returned by fmt->Object() for 
IID_IQPushButton ({06831CC9-59B6-436A-9578-6D53E5AD03D3}) work?


Volker


--
 [ signature omitted ] 

Message 5 in thread

>What error message do you get for the last call?
>  
>
No any error message came up, and program went through smoothly, but 
setText() does not functioning.
--- no text appears on the button. Similar function with capital "S" in 
MFC gives the button text.

>Does QueryInterface'ing the interface returned by fmt->Object() for 
>IID_IQPushButton ({06831CC9-59B6-436A-9578-6D53E5AD03D3}) work?
>
>
>  
>
        void *ptr;
        long n = 
fmt->queryInterface("{06831CC9-59B6-436A-9578-6D53E5AD03D3}",&ptr); // 
ifaceid
        long m = 
fmt->queryInterface("{2B262458-A4B6-468B-B7D4-CF5FEE0A7092}",&ptr); // 
classid
In both cases ptr is NULL.


--
 [ signature omitted ] 

Message 6 in thread

>>What error message do you get for the last call?
>>
> No any error message came up, and program went through smoothly, but 
> setText() does not functioning.

Don't you get any debug output?


>>Does QueryInterface'ing the interface returned by fmt->Object() for 
>>IID_IQPushButton ({06831CC9-59B6-436A-9578-6D53E5AD03D3}) work?
>>
>>
>>
>        void *ptr;
>        long n = 
> fmt->queryInterface("{06831CC9-59B6-436A-9578-6D53E5AD03D3}",&ptr); // 
> ifaceid
>        long m = 
> fmt->queryInterface("{2B262458-A4B6-468B-B7D4-CF5FEE0A7092}",&ptr); // 
> classid
> In both cases ptr is NULL.


Then the COM object returned is not the QPushButton.

Volker


--
 [ signature omitted ]