[Qt-interest] QTabWidget::currentWidget() problem
Keshava Krishna
keshavkrishna88 at gmail.com
Sat Apr 4 06:08:14 CEST 2009
No, textEditor[0] is valid...
i think the problem is with the signal slot connection...
On Sat, Apr 4, 2009 at 12:41 AM, Malyushytsky, Alex <alex at wai.com> wrote:
> Mostly likely
>
> textEditorArray[0] contains invalid pointer. Check it.
>
> Alex
>
>
>
>
> Alex Malyushytsky
> Research Engineer - Weidlinger Associates Inc.
> office: 650 230 0210,
> direct: 650 230 0349
> web: http://www.wai.com
> ________________________________________
> From: Keshava Krishna [mailto:keshavkrishna88 at gmail.com]
> Sent: Thursday, April 02, 2009 8:31 PM
> To: Malyushytsky, Alex
> Cc: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] QTabWidget::currentWidget() problem
>
> Is this happening because i called "
> textTab->setCurrentWidget(textEditorArray[0]);"
> in a slot that has been connected to "textTab->currentChanged(int)" ??
> Can anyone help me out?
>
> Regards,
> Keshava.
> On Wed, Apr 1, 2009 at 10:50 AM, Keshava Krishna <
> keshavkrishna88 at gmail.com> wrote:
> Thanks Alex, the code you gave worked...
>
> But 'm facing a new problem now....
> 'm trying to give a fading effect while user clicks on a tab
> i have used the following signal connection for this pupose
>
>
> connect(textTab,SIGNAL(currentChanged(int)),this,SLOT(tabTransformation()));
>
> and the tabTransformation function is like this..
>
> void Win::tabTransformation()
> {
>
> QColor *color1 = new QColor(255,255,255,0);
> QTextEdit *ptr1 = qobject_cast< QTextEdit *>(textTab->currentWidget());
> textTab->setCurrentWidget(textEditorArray[0]);
> QPalette *palette = new QPalette();
> for(int i=0;i<10;i++)
> {
> *color1 = QColor::fromRgbF(1,1,1,1*(i+1)/10);
> palette->setColor(QPalette::Active,QPalette::Base,*color1);
> ptr1->setPalette(*palette);
> palette->setColor(QPalette::Inactive,QPalette::Base,*color1);
> ptr1->setPalette(*palette);
> textEditorArray[0]->show();
> QTest::qWait(100);
> }
>
> }
>
> but now when i open a new tab (in textTab), it is giving segmentation
> fault... by using qDebug(0 i discovered that the following line is giving
> the segmentation fault..
> ptr1->setPalette(*palette); this
>
> Can anyone suggest me why is this happening, please suggest me a better way
> way acomplishing this task..
>
> Regards,
> Keshava.
>
>
> On Wed, Apr 1, 2009 at 1:48 AM, Malyushytsky, Alex <alex at wai.com> wrote:
> >> Before this used to be a warning and my program was working fine, but
> now it has become an error( 'm really surprised )
> I guess you changed compiler.
> Use a proper cast. I would recommend qobject_cast in this case:
>
>
> QTextEdit *ptr1 = qobject_cast< QTextEdit *>(obj);
>
> Regards,
> Alex
>
> ________________________________________
> From: qt-interest-bounces at trolltech.com [mailto:
> qt-interest-bounces at trolltech.com] On Behalf Of Keshava Krishna
> Sent: Tuesday, March 31, 2009 5:20 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] QTabWidget::currentWidget() problem
>
> Hi,
> 'm using a tabwidget to which 'm adding many QTextEdit s...
> now i want to get a pointer to the currently activated widget...
> i used the following code
>
> QTextEdit *ptr1 = textTab->currentWidget();
>
> but it is giving the following error
>
> Win.cpp:846: error: invalid conversion from 'QWidget*' to 'QTextEdit*'
>
> Before this used to be a warning and my program was working fine, but now
> it has become an error( 'm really surprised )
>
> can anyone help me out to debug this ?
>
> Regards ,
> Keshava.
>
>
> ---------------------------------------------------------------------------------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> "This message and any attachments are solely for the intended recipient and
> may contain confidential or privileged information. If you are not the
> intended recipient, any disclosure, copying, use, or distribution of the
> information included in this message and any attachments is prohibited. If
> you have received this communication in error, please notify us by reply
> e-mail and immediately and permanently delete this message and any
> attachments. Thank you."
>
> "Please consider our environment before printing this email."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
> "This message and any attachments are solely for the intended recipient and
> may contain confidential or privileged information. If you are not the
> intended recipient, any disclosure, copying, use, or distribution of the
> information included in this message and any attachments is prohibited. If
> you have received this communication in error, please notify us by reply
> e-mail and immediately and permanently delete this message and any
> attachments. Thank you."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090404/bec470bf/attachment.html
More information about the Qt-interest-old
mailing list