示例#1
0
SEXP
qt_qsceneView(SEXP scene)
{
    QGraphicsView *v = new QGraphicsView(unwrapSmoke(scene, QGraphicsScene), 0);
    v->setRenderHints(QPainter::TextAntialiasing);
    v->setInteractive(true);
    // v->setDragMode(QGraphicsView::RubberBandDrag);
    v->setDragMode(QGraphicsView::ScrollHandDrag);
    return wrapSmoke(v, QGraphicsView, true);
}
示例#2
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QDir::setCurrent(QCoreApplication::applicationDirPath());
    QDir dir(QDir::current());

    // set the slide model.
    QFile xmlf(dir.absoluteFilePath("userdata/test.xml"));
    if (!xmlf.exists()) {
        QMessageBox::critical(0, "error", "no xml file...");
        return 0;
    }
    xmlf.open(QFile::ReadWrite);
    QSlideModel model(xmlf.readAll());
    xmlf.close();


    // set the slide scene
    QSlidePlayerScene *scene = new QSlidePlayerScene(0, &model);
    QPixmap pixmap(dir.absoluteFilePath("res/images/default-background.png"));
    scene->setBackgroundBrush(Qt::black);
    scene->setBackgroundPixmap(pixmap);

    //set slide view
    QGraphicsView *view = new QGraphicsView(scene);

    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setFrameShape(QFrame::NoFrame);
    // editing is not allowed.
    view->setInteractive(false);

    // scale
    double newScale = QApplication::desktop()->height() / scene->sceneRect().height();
    QMatrix oldMatrix = view->matrix();
    view->resetMatrix();
    view->translate(oldMatrix.dx(), oldMatrix.dy());
    view->scale(newScale, newScale);

    view->showFullScreen();

    QHidDevice * test = new QHidDevice(0x55, 0x32, &a);

    return a.exec();
}
void PieceAppearanceWidget::setupUI()
{
    QLayout * lay = new QGridLayout( this );
    lay->setSpacing(0);
    lay->setContentsMargins(0,0,0,0);
    QGraphicsView * v = this->impl->gv =
	//new QGraphicsView( impl->gs.scene() )
	new QBoardView( impl->gs )
	;

    v->setTransformationAnchor(QGraphicsView::NoAnchor);
#if 0
    v->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    v->setInteractive(true); // required to get mouse events to the children
    v->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
    v->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
    v->setDragMode(QGraphicsView::RubberBandDrag);
    v->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
#endif
    v->setBackgroundBrush(QColor("#abb8fb"));
    v->viewport()->setObjectName( "PieceAppearanceWidget");

    lay->addWidget( v );

    QStringList tip;
    tip << "<html><body>These widgets are appearance templates for game pieces.\n"
	<< "Edit them by right-clicking them.\n"
	<< "Select a template by left-clicking it. "
	<< "QBoard will use the selected template as the default look\n"
	<< "for newly-added pieces which are loaded from image files.\n"
	<< "This list will be saved automatically when QBoard exits,\n"
	<< "and loaded when QBoard starts up.</body></html>"
	;
    impl->gv->setToolTip( tip.join("") );

}