Shawn
29th June 2007, 08:51
test::test(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QString str = "test";
pixTrans.load("Resources/Trans.bmp");
view.setScene(&scene);
setCentralWidget(&view);
showText(&str,0,0);
showItem(&pixTrans,0,0);
showText(&str,0,100);
showItem(&pixTrans,0,100);
}
void test::showItem(QPixmap *pixmap, int x, int y)
{
QGraphicsPixmapItem* i = scene.addPixmap(*pixmap);
i->setPos(x,y);
}
void test::showText(QString *str, int x, int y)
{
QGraphicsTextItem* i = scene.addText(*str);
i->setPos(x, y);
}
the result is so strange:
the 1st text "test" at (0,0) is covered by the pixmap "pixTrans"
while the 2nd text "test" at (0,0) is on top of the pixmap "pixTrans"
I want to show text on top of pixmap at the same coordinate (x,y), is there any way to do this ?
thanks very much for suggestion!
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QString str = "test";
pixTrans.load("Resources/Trans.bmp");
view.setScene(&scene);
setCentralWidget(&view);
showText(&str,0,0);
showItem(&pixTrans,0,0);
showText(&str,0,100);
showItem(&pixTrans,0,100);
}
void test::showItem(QPixmap *pixmap, int x, int y)
{
QGraphicsPixmapItem* i = scene.addPixmap(*pixmap);
i->setPos(x,y);
}
void test::showText(QString *str, int x, int y)
{
QGraphicsTextItem* i = scene.addText(*str);
i->setPos(x, y);
}
the result is so strange:
the 1st text "test" at (0,0) is covered by the pixmap "pixTrans"
while the 2nd text "test" at (0,0) is on top of the pixmap "pixTrans"
I want to show text on top of pixmap at the same coordinate (x,y), is there any way to do this ?
thanks very much for suggestion!