[Qt-interest] QGraphicsItem can not show the cursor
christopherx
christopherx at xandros.com
Wed May 6 20:20:47 CEST 2009
Hello all:
I have made a simple program to show the problem:
#include <QtGui/QtGui>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QGroupBox *groupBox = *new* QGroupBox("Contact Details");
QLabel *numberLabel = *new* QLabel("Telephone number");
QLineEdit *numberEdit = *new* QLineEdit;
QFormLayout *layout = *new* QFormLayout;
layout->addRow(numberLabel, numberEdit);
groupBox->setLayout(layout);
QGraphicsScene scene;
QGraphicsProxyWidget *proxy = scene.addWidget(groupBox);
///numberEdit->setFocus();/
QGraphicsView view(&scene);
view.show();
*return* app.exec();
}
I like to see the cursor in numberEdit field when the form is first
show.
With the setFocus() call, I only got keyboard focus. Is this a
limitation of QGraphicsProxyWidget ?
or I missed anything ?
Thanks,
Chris Xu
christopherx wrote:
> Hello Fred:
>
> I have built the same porject without the QGraphicsView/Scene
> framework, and it works fine. The text cursor is showed, and tab order
> is correct as set in the ui file.
>
> Is this a Qt bug, or I missed something ?
>
> Thanks,
> Chris Xu
>
> Fred Duarte wrote:
>
>> The way i made it transparent was by changing the widget's pallete.
>>
>> I'm using this piece of code:
>>
>> *QPalette palette(widget->palette());
>> palette.setColor(widget->backgroundRole(), Qt::transparent);
>> *
>> *widget->setPalette(**palette);*
>>
>> and it works fine. But i still can't make the damm cursor appear
>> on the screen when i attach the widget to a scene.
>>
>> Ideas, anyone?
>>
>>
>> On Mon, Apr 27, 2009 at 5:48 PM, christopherx
>> <christopherx at xandros.com <mailto:christopherx at xandros.com>> wrote:
>>
>> Sorry Fred, My statment in last message DOES NOT working.
>> What's yours ?
>>
>> Thanks,
>>
>> Fred Duarte wrote:
>>
>> I'm having a similar problem.
>> My QLineEdit object inside a QGraphicsProxyWidget is not showing
>> the cursor. Even when I click on the widget and it gain focus,
>> the cursor is
>> still hidden.
>> A made just a small change on my widget, where i set the
>> background to
>> transparent. But that's it. I still add it to the scene
>> through a QGraphicsProxyWidget.
>>
>> On Mon, Apr 27, 2009 at 11:28 AM, christopherx
>> <christopherx at xandros.com <mailto:christopherx at xandros.com>
>> <mailto:christopherx at xandros.com
>> <mailto:christopherx at xandros.com>>> wrote:
>>
>> Hello all:
>>
>> I have a problem with cursor is not showing in the
>> QEditline.
>> Please let me know if you know the issue. Thanks.
>> I have a widget which contains a QEditline an a few
>> QLabel, a
>> QListview and a buttonBox. And the widget is sign to a
>> QGraphicsItem
>> as a proxywidget as :
>>
>> grpItem = new GraphicsRectItem(QRectF,
>> myWidget->palette().window(), myWidget).
>>
>> And the grpItem is a child of a baseItem (which is the same
>> type as
>> grpItem, a GraphicsRectItem). The baseItem is added to a
>> QGraphicsScene, and the scene is a member of set to a
>> GraphicsView.
>>
>> After the creation of the grpItem, I did a
>> QEditLine->setFocuse(),
>> and it works, the edit line does got the keyboard focus, but I
>> can't see
>> the Cursor unless I click on the widget/or editline. Also,
>> the tab
>> order is not working on the widget.
>>
>> Please help.
>>
>> Thanks,
>> --
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> <mailto:Qt-interest at trolltech.com>
>> <mailto:Qt-interest at trolltech.com
>> <mailto:Qt-interest at trolltech.com>>
>>
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>>
>>
>> --
>> Frederico Simas Duarte
>> MLS - Mobile Linux Software
>> INDT - Nokia Institute
>>
>>
>> --
>>
>> Christopher Xu
>>
>>
>>
>>
>> --
>> Frederico Simas Duarte
>> MLS - Mobile Linux Software
>> INDT - Nokia Institut
>>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
Christopher Xu
More information about the Qt-interest-old
mailing list