Re: font can not be changed
Did u try something like this inside the paint( ) function? So you can set the appropriate font.
Code:
painter
->setFont
(QFont("Times",
18));
QRectF rect
(10.0,
20.0,
80.0,
60.0);
painter->drawText(rect, Qt::AlignCenter, ("Qt by\nTrolltech"));
Re: font can not be changed
I think you have not undertood my problem.
If i need to chage the font at runtime then your code will not allow me that.Because you have hardcoded the font.
I already mentioned that there is toolbar which has QFontComboBox which shows list of font.Selected font from this combobox is then i am trying to give it to my customized item.
e.g.
Code:
void customizedItem
::setItemFont(QFont ft
) // which is called from font toolbar {
m_textFont = ft ; // at this point i m getting exception which i have pasted below
}
#if defined(QT_NO_EXCEPTIONS)
receiver
->qt_metacall
(QMetaObject::InvokeMetaMethod, method, argv ? argv
: empty_argv
);
#else
try
{
receiver
->qt_metacall
(QMetaObject::InvokeMetaMethod, method, argv ? argv
: empty_argv
);
}
catch (...)
{
locker.relock();
QObjectPrivate::resetCurrentSender(receiver, ¤tSender, previousSender);
--connectionLists->inUse;
Q_ASSERT(connectionLists->inUse >= 0);
if (connectionLists->orphaned && !connectionLists->inUse)
delete connectionLists;
throw;
}
#endif
Note : even i am unable to modify any member variable my cusomized item in this setItemFont() method . i.e same exeption as above
Is anything i doing wrong.
Thanks
Re: font can not be changed
Quote:
Originally Posted by
ashishsaryar
I think you have not understood my problem.
If i need to chage the font at runtime then your code will not allow me that.Because you have hardcoded the font.
Is anything i doing wrong.
Thanks
I think what user_mail07 meant was (using your setItemFont() function to set the font):
Code:
painter->setFont(m_textFont);
QRectF rect
(10.0,
20.0,
80.0,
60.0);
// or whatever box you need painter->drawText(rect, Qt::AlignCenter, ("Qt by\nTrolltech")); // or whatever text you need
Vycke
Re: font can not be changed
Sorry ...I got my mistake .
I did nt set Item Flag to be IsItemFocusable .
This is the reason , i am unable to modify any member variable of this Class .