test
::test(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
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
) {
i->setPos(x,y);
}
void test
::showText(QString *str,
int x,
int y
) {
i->setPos(x, y);
}
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);
}
To copy to clipboard, switch view to plain text mode
the result is so strange:
Bookmarks