Discussion:
Can MTF application use QWidget?
Pai, Cary
2011-04-14 02:13:37 UTC
Permalink
Hi, All,

I have created a MTF application, but when I run the application with the QPushButton add into MApplicationPage, it will have the segmentation fault, why MTF can't add the QWidget based item? The code I wrote are as below :

int main(int argc, char *argv[])
{
MApplication a(argc, argv);
MApplicationWindow w;
MApplicationPage p;
QPushButton* but = new QPushButton("test");
p.scene()->addWidget(but);
p.appear(&w);
w.show();
return a.exec();
}

Since the p.scene() is QGraphicsScene why it will have the error on runtime?

Best Regards.

Intel Software & Service Group

[cid:image001.jpg-***@public.gmane.org]

B1 #205 Tun-Hwa North Rd, Taipei, Taiwan

Desk

+886-2-2514-4603

Mobile

+886-987-369-617

E-Mail

cary.pai-***@public.gmane.org<mailto:gorden.nieh-***@public.gmane.org>
Chen, Zhang Z
2011-04-14 02:55:57 UTC
Permalink
Forwarding to meego-dev

From: meego-sdk-bounces-***@public.gmane.org [mailto:meego-sdk-bounces-***@public.gmane.org] On Behalf Of Pai, Cary
Sent: Thursday, April 14, 2011 10:14 AM
To: meego-sdk-***@public.gmane.org
Subject: [MeeGo-SDK] Can MTF application use QWidget?

Hi, All,

I have created a MTF application, but when I run the application with the QPushButton add into MApplicationPage, it will have the segmentation fault, why MTF can't add the QWidget based item? The code I wrote are as below :

int main(int argc, char *argv[])
{
MApplication a(argc, argv);
MApplicationWindow w;
MApplicationPage p;
QPushButton* but = new QPushButton("test");
p.scene()->addWidget(but);
p.appear(&w);
w.show();
return a.exec();
}

Since the p.scene() is QGraphicsScene why it will have the error on runtime?

Best Regards.

Intel Software & Service Group

[cid:image001.jpg-KuN/ryDjG+***@public.gmane.org]

B1 #205 Tun-Hwa North Rd, Taipei, Taiwan

Desk

+886-2-2514-4603

Mobile

+886-987-369-617

E-Mail

cary.pai-***@public.gmane.org<mailto:gorden.nieh-***@public.gmane.org>
Rusty Lynch
2011-04-14 04:12:35 UTC
Permalink
Post by Chen, Zhang Z
Forwarding to meego-dev
*Sent:* Thursday, April 14, 2011 10:14 AM
*Subject:* [MeeGo-SDK] Can MTF application use QWidget?
Hi, All,
I have created a MTF application, but when I run the application with
the QPushButton add into MApplicationPage, it will have the
segmentation fault, why MTF can’t add the QWidget based item? The code
int main(int argc, char *argv[])
{
MApplication a(argc, argv);
MApplicationWindow w;
MApplicationPage p;
QPushButton* but = new QPushButton("test");
p.scene()->addWidget(but);
p./appear/(&w);
w.show();
return a.exec();
}
Since the p.scene() is QGraphicsScene why it will have the error on runtime?
Your attempting to mix QGraphics programing with QWidget programming.
It is possible to wrap a QWidget for use in a QGraphicsView, but it
comes at a cost and is usually the wrong answer.

For example... if you wanted to add button into an MTF based app, just
use MButton (or whatever the name of the associated button class is.)

I would advise sitting down and reading through all the QGraphicsView
programming documentation and tutorials that come with Qt. Once you
comprehend QGraphicsView then MTF programming will make a lot more sense.

--rusty
Pai, Cary
2011-04-14 07:54:36 UTC
Permalink
Hi, Rusty,

Thanks for the response, I have a question about using the MButton, I want to create a button which is only showing the Icon on MButton, when I use "setViewType(MButton::iconType);", the icon can only display in a fix size no matter what I change the icon-size attribute in the CSS file, but if I do not use "setViewType(MButton::iconType);" , the Icon can show the size that I set in the CSS file, but it will have the square button outline under the icon, please tell me how to show an icon button without back square button outline, and showing the exactly size I want, thanks.

Best Regards.

Intel Software & Service Group

[cid:image001.jpg-***@public.gmane.org]

B1 #205 Tun-Hwa North Rd, Taipei, Taiwan

Desk

+886-2-2514-4603

Mobile

+886-987-369-617

E-Mail

cary.pai-***@public.gmane.org<mailto:gorden.nieh-***@public.gmane.org>



From: Lynch, Rusty
Sent: Thursday, April 14, 2011 12:13 PM
To: Chen, Zhang Z
Cc: Pai, Cary; meego-sdk-***@public.gmane.org; meego-dev-***@public.gmane.org
Subject: Re: [MeeGo-dev] Can MTF application use QWidget?

On 04/13/2011 07:55 PM, Chen, Zhang Z wrote:
Forwarding to meego-dev

From: meego-sdk-bounces-***@public.gmane.org<mailto:meego-sdk-bounces-***@public.gmane.org> [mailto:meego-sdk-bounces-***@public.gmane.org] On Behalf Of Pai, Cary
Sent: Thursday, April 14, 2011 10:14 AM
To: meego-sdk-***@public.gmane.org<mailto:meego-sdk-***@public.gmane.org>
Subject: [MeeGo-SDK] Can MTF application use QWidget?

Hi, All,

I have created a MTF application, but when I run the application with the QPushButton add into MApplicationPage, it will have the segmentation fault, why MTF can't add the QWidget based item? The code I wrote are as below :

int main(int argc, char *argv[])
{
MApplication a(argc, argv);
MApplicationWindow w;
MApplicationPage p;
QPushButton* but = new QPushButton("test");
p.scene()->addWidget(but);
p.appear(&w);
w.show();
return a.exec();
}

Since the p.scene() is QGraphicsScene why it will have the error on runtime?

Your attempting to mix QGraphics programing with QWidget programming. It is possible to wrap a QWidget for use in a QGraphicsView, but it comes at a cost and is usually the wrong answer.

For example... if you wanted to add button into an MTF based app, just use MButton (or whatever the name of the associated button class is.)

I would advise sitting down and reading through all the QGraphicsView programming documentation and tutorials that come with Qt. Once you comprehend QGraphicsView then MTF programming will make a lot more sense.

--rusty
Tyler Starke
2011-04-14 03:32:58 UTC
Permalink
You don't add QWidget's to a QGraphicsScene. You need to look at the The Graphics View Framework and the types of widgets one can accept. You might be able to add your QPushButton to a QGraphicsProxyWidget and then add that proxy widget to the scene (Scene.addItem(proxy)). I am not sure, I have not used regular widgets inside a QGraphicsScene before.

 
=-=-=-=-=-=-=-=-=-=-=-=-=S=-=-=-=-=I=-=-=-=-=G=-=-=-=-=-=-=-=-=-=
Company Home: Mad Mathematics Laboratories


The new and redesigned: Knowledge Arcana Magazine

Products Arcana! at RPG Now



________________________________
From: "Chen, Zhang Z" <zhang.z.chen-***@public.gmane.org>
To: "Pai, Cary" <cary.pai-***@public.gmane.org>; "meego-sdk-***@public.gmane.org" <meego-sdk-***@public.gmane.org>; "meego-***@meego.com" <meego-dev-***@public.gmane.org>
Sent: Wednesday, April 13, 2011 9:55 PM
Subject: Re: [MeeGo-SDK] Can MTF application use QWidget?



Forwarding
to meego-dev
 
From:meego-sdk-bounces-***@public.gmane.org
[mailto:meego-sdk-bounces-***@public.gmane.org] On Behalf Of Pai, Cary
Sent: Thursday, April 14, 2011 10:14 AM
To: meego-sdk-***@public.gmane.org
Subject: [MeeGo-SDK] Can MTF application use QWidget?
 
Hi, All,
 
I have created a MTF application, but when
I run the application with the QPushButton add into MApplicationPage, it will
have the segmentation fault, why MTF can’t add the QWidget based item?
The code I wrote are as below :
 
intmain(intargc,char*argv[])
{
   
MApplicationa(argc,argv);
    MApplicationWindoww;
    MApplicationPagep;
    QPushButton*but=newQPushButton("test");
    p.scene()->addWidget(but);
   
p.appear(&w);
    w.show();
    returna.exec();
}
 
Since the p.scene() is QGraphicsScene why
it will have the error on runtime?
 
Best Regards.
 
Intel Software & Service Group        
B1 #205 Tun-Hwa North Rd, Taipei, Taiwan
Desk +886-2-2514-4603
Mobile +886-987-369-617
E-Mail cary.pai-***@public.gmane.org
 
 
_______________________________________________
MeeGo-sdk mailing list
MeeGo-sdk-***@public.gmane.org
http://lists.meego.com/listinfo/meego-sdk
http://wiki.meego.com/Mailing_list_guidelines
http://meego.com/developers
Thiago Macieira
2011-04-14 06:33:23 UTC
Permalink
Post by Tyler Starke
You don't add QWidget's to a QGraphicsScene. You need to look at the The
Graphics View Framework and the types of widgets one can accept. You might
be able to add your QPushButton to a QGraphicsProxyWidget and then add that
proxy widget to the scene (Scene.addItem(proxy)). I am not sure, I have not
used regular widgets inside a QGraphicsScene before.
You could do that, but I highly recommend against it, for two big reasons:

1) using QGraphicsProxyWidget will give you a big drop in performance; avoid
it

2) standard Qt widgets will not look properly themed in MeeGo Handset. We
tried for a long time to make them look ok, but in the end we had to settle
for "it reminds us of the look and feel". QWidget's architecture is just too
limited for the UX guidelines we came up with for more modern platforms.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
Pai, Cary
2011-04-14 10:11:01 UTC
Permalink
Hi, Macieira,

But why after I add the QWidget in the scene in the QApplicationPage instance, it will crash?

Best Regards.

Intel Software & Service Group
       
B1 #205 Tun-Hwa North Rd, Taipei, Taiwan

Desk
+886-2-2514-4603

Mobile
+886-987-369-617

E-Mail
cary.pai-***@public.gmane.org



-----Original Message-----
From: meego-sdk-bounces-***@public.gmane.org [mailto:meego-sdk-bounces-***@public.gmane.org] On Behalf Of Thiago Macieira
Sent: Thursday, April 14, 2011 2:33 PM
To: meego-sdk-***@public.gmane.org
Subject: Re: [MeeGo-SDK] Can MTF application use QWidget?
Post by Tyler Starke
You don't add QWidget's to a QGraphicsScene. You need to look at the
The Graphics View Framework and the types of widgets one can accept.
You might be able to add your QPushButton to a QGraphicsProxyWidget
and then add that proxy widget to the scene (Scene.addItem(proxy)). I
am not sure, I have not used regular widgets inside a QGraphicsScene before.
You could do that, but I highly recommend against it, for two big reasons:

1) using QGraphicsProxyWidget will give you a big drop in performance; avoid it

2) standard Qt widgets will not look properly themed in MeeGo Handset. We tried for a long time to make them look ok, but in the end we had to settle for "it reminds us of the look and feel". QWidget's architecture is just too limited for the UX guidelines we came up with for more modern platforms.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358

Loading...