[Qt-interest] QTabWidget::currentWidget() problem
Keshava Krishna
keshavkrishna88 at gmail.com
Wed Apr 1 07:20:21 CEST 2009
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090401/1786a565/attachment.html
More information about the Qt-interest-old
mailing list