コード例 #1
0
ファイル: GridView.cpp プロジェクト: detiq-t/detiq-t_old
GridView::GridView(const imagein::Image* im, int dx, int dy)
  : AlternativeImageView(im)
{
    _layout = new QHBoxLayout;
    _viewer = new ImageViewer(im, dx, dy);

    QVBoxLayout *layout = new QVBoxLayout();

    QGraphicsView* view = new QGraphicsView;
    view->setScene(_viewer);

    RadioPanel* panel = new RadioPanel(im->getNbChannels());

    layout->addWidget(view);
    layout->addWidget(panel);
    _layout->addLayout(layout);

    ZoomViewer* zv = new ZoomViewer(im, ImageViewer::RECT_W, ImageViewer::RECT_H);
    QGraphicsView* viewz = new QGraphicsView;
    viewz->setScene(zv);
    _layout->addWidget(viewz);

    QObject::connect(panel, SIGNAL(activated(int)), zv, SLOT(channelChosen(int)));

    QObject::connect(_viewer, SIGNAL(positionUpdated(int, int)), zv, SLOT(draw(int, int)));

    setLayout(_layout);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: RLED/ProjectRichelBilderbeek
int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  QGraphicsView w;

  assert(!w.scene());
  w.setScene(new QGraphicsScene);
  assert(w.scene());

  {
    TrianglePolygonItem * const item = new TrianglePolygonItem;
    item->setPos(-150.0,-150.0);
    w.scene()->addItem(item);
  }
  {
    TrianglePolygonItem * const item = new TrianglePolygonItem;
    item->setBrush(QBrush(QColor(0,0,0)));
    item->setPos(150.0,-150.0);
    w.scene()->addItem(item);
  }
  {
    TriangleGraphicsItem * const item = new TriangleGraphicsItem;
    item->setPos(-150.0, 150.0);
    w.scene()->addItem(item);
  }
  {
    TriangleGraphicsItem * const item = new TriangleGraphicsItem;
    item->SetMyBrush(QBrush(QColor(0,0,0)));
    item->setPos(150.0, 150.0);
    w.scene()->addItem(item);
  }
  w.show();

  return a.exec();
}
コード例 #3
0
ファイル: widget.cpp プロジェクト: Qmax/PT6
//void Widget::HardwareInitializtaion(){
//qDebug()<<"AWG Hardware Initialisation";
//}
void Widget::enableRichGUI(){
	QWidget *m_objWidget=new QWidget(this);
	QGraphicsScene *entireScene = new QGraphicsScene(0,0,800,600);
	QGraphicsView  *entireView =  new QGraphicsView(m_objWidget);
	QPixmap obj1 = QPixmap(":/bg.png");
	QBrush obj2 = QBrush(obj1);
	obj2.setStyle(Qt::TexturePattern);
	obj2.setTexture(obj1);
	entireView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	entireView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	entireView->setFrameStyle(QFrame::Plain|QFrame::Sunken);
	entireView->setBackgroundBrush(obj2);
	entireView->setScene(entireScene);
	entireView->setGeometry(0,0,800,600);

	ui->groupBox->setParent(m_objWidget);
	ui->groupBox_2->setParent(m_objWidget);
	ui->groupBox_3->setParent(m_objWidget);
	ui->grpGeneral->setParent(m_objWidget);
	ui->grpSettings->setParent(m_objWidget);
	ui->grpWaveConfiguration->setParent(m_objWidget);
	ui->grpWaveWindow->setParent(m_objWidget);

	ui->grpGeneral->setGeometry(20,0,271,160);
	ui->groupBox->setGeometry(510,430,271,90);
	ui->groupBox_2->setGeometry(310,350,191,170);
	ui->grpSettings->setGeometry(310,0,471,101);
	ui->grpWaveConfiguration->setGeometry(20,164,271,356);
	ui->groupBox_3->setGeometry(510,360,271,77);
	ui->grpWaveWindow->setGeometry(310,100,471,250);

}
コード例 #4
0
ファイル: main.cpp プロジェクト: NahomKidane/QtExamples
int main( int argc, char **argv )
{
  QApplication app( argc, argv );
  
  QGraphicsScene scene( 0, 0, 200, 200 );
  
  QGraphicsRectItem *rectItem = new QGraphicsRectItem( QRect( 10, 10, 50, 100 ), 0, &scene );
  QGraphicsEllipseItem *elItem = new QGraphicsEllipseItem( QRect( 80, 40, 100, 80 ), 0, &scene );
  
  HandleItem *trh = new HandleItem( rectItem, &scene, Qt::red, HandleItem::TopHandle );
  HandleItem *rrh = new HandleItem( rectItem, &scene, Qt::red, HandleItem::RightHandle );
  HandleItem *crh = new HandleItem( rectItem, &scene, Qt::red, HandleItem::CenterHandle, QList<HandleItem*>() << trh << rrh );
  
  HandleItem *teh = new HandleItem( elItem, &scene, Qt::green, HandleItem::TopHandle );
  HandleItem *reh = new HandleItem( elItem, &scene, Qt::green, HandleItem::RightHandle );
  HandleItem *ceh = new HandleItem( elItem, &scene, Qt::green, HandleItem::CenterHandle, QList<HandleItem*>() << teh << reh );

  QGraphicsView view;
  view.setScene( &scene );
  view.show();
  
  int res = app.exec();
  
  delete crh;
  delete trh;
  delete rrh;
    
  delete ceh;
  delete teh;
  delete reh;
  
  return res;
}
コード例 #5
0
ファイル: scorewindow.cpp プロジェクト: sh4869/TankGame
ScoreWindow::ScoreWindow() : QWidget(0)
{
    topnum = 0;
    nowScore = 0;
    scoreScene = new QGraphicsScene(0,0,1024,768);
    scoreText = new QGraphicsTextItem();
    scorefont = scoreText->font();
    scorefont.setPointSize(300);
    scorefont.setBold(true);

    scoreText->setPlainText("Hello");
    scoreText->setPos(20,150);
    scoreText->setDefaultTextColor(Qt::yellow);
    scoreText->setFont(scorefont);


    topScore = new QGraphicsTextItem();
    topfont = topScore->font();
    topfont.setPointSize(50);
    topScore->setPlainText("");
    topScore->setPos(400,600);
    topScore->setDefaultTextColor(Qt::green);
    topScore->setFont(topfont);


    scoreScene->addItem(topScore);
    scoreScene->addItem(scoreText);

    QGraphicsView *scoreView = new QGraphicsView();
    scoreView->setScene(scoreScene);
    QVBoxLayout *scoreLayout = new QVBoxLayout();
    scoreLayout->addWidget(scoreView);
    setLayout(scoreLayout);
    //changeScore(133,20);
}
コード例 #6
0
ファイル: widget.cpp プロジェクト: Qmax/PT6
//void Widget::HardwareInitializtaion(){
//qDebug()<<"ICM Hardware Initialisation";
//}
void Widget::enableRichGUI(){
	QWidget *m_objWidget=new QWidget(this);
	QGraphicsScene *entireScene = new QGraphicsScene(0,0,800,600);
	QGraphicsView  *entireView =  new QGraphicsView(m_objWidget);
	QPixmap obj1 = QPixmap(":/bg.png");
	QBrush obj2 = QBrush(obj1);
	obj2.setStyle(Qt::TexturePattern);
	obj2.setTexture(obj1);
	entireView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	entireView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	entireView->setFrameStyle(QFrame::Plain|QFrame::Sunken);
	entireView->setBackgroundBrush(obj2);
	entireView->setScene(entireScene);
	entireView->setGeometry(0,0,800,600);

	ui->grpGeneral->setParent(m_objWidget);
	ui->groupBox->setParent(m_objWidget);
	ui->grpSettings->setParent(m_objWidget);
	ui->groupBox_2->setParent(m_objWidget);
	ui->groupBox_4->setParent(m_objWidget);
	ui->groupBox_3->setParent(m_objWidget);


	ui->grpGeneral->setGeometry  (20,  0,   271, 161);
	ui->groupBox->setGeometry    (20,  160, 271, 360);
	ui->grpSettings->setGeometry (309, 0,   474, 131);
	ui->groupBox_2->setGeometry  (309, 130, 474, 91 );
	ui->groupBox_4->setGeometry  (310, 230, 171, 290);
	ui->groupBox_3->setGeometry  (489, 220, 294, 300);

}
コード例 #7
0
ファイル: main.cpp プロジェクト: lorn/c_sandbox
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget w;
    QGraphicsView *view = new QGraphicsView;
    QGraphicsScene scene;
    view->setScene(&scene);
    SmileyItem *item = new SmileyItem;
    scene.addItem(item);
    item->setFlag(QGraphicsItem::ItemIsMovable);

    QSlider *slider = new QSlider(Qt::Horizontal);
    slider->setRange(0,100);
    slider->setValue(item->smileSize());
    QObject::connect(slider, SIGNAL(valueChanged(int)), item, SLOT(setSmileSize(int)));
    QObject::connect(item, SIGNAL(smileSizeChanged(int)), slider, SLOT(setValue(int)));

    QVBoxLayout *l = new QVBoxLayout(&w);
    l->addWidget(view);
    l->addWidget(slider);

    view->setRenderHint(QPainter::Antialiasing);
    w.show();
    w.resize(600,400);
    return a.exec();
}
コード例 #8
0
ファイル: dashboard.cpp プロジェクト: Herrie82/webos-keyboard
Dashboard::Dashboard(QWidget *parent)
    : QMainWindow(parent)
    , d_ptr(new DashboardPrivate(this))
{
    setWindowTitle("Maliit Keyboard Viewer");
    resize(854, 480);

    QGraphicsView *v = new QGraphicsView;
    v->setScene(new QGraphicsScene(v));
    v->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    v->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setCentralWidget(v);
    v->show();
    QWidget *w = 0;
    d_ptr->proxy_widget = v->scene()->addWidget(w = new QWidget);
    d_ptr->proxy_widget->setTransformOriginPoint(d_ptr->proxy_widget->geometry().center());
    w->resize(size());

    QVBoxLayout *vbox = d_ptr->vbox;
    w->setLayout(vbox);

    QSpacerItem *top_spacer = d_ptr->top;
    vbox->addItem(top_spacer);

    QWidget *buttons = d_ptr->buttons;
    buttons->show();
    vbox->addWidget(buttons);
    QHBoxLayout *hbox = new QHBoxLayout;
    buttons->setLayout(hbox);

    QPushButton *show = new QPushButton("Show virtual keyboard");
    connect(show, SIGNAL(clicked()),
            this, SLOT(onShow()));
    hbox->addWidget(show);
    show->show();

    QPushButton *orientation_changed = new QPushButton("Change orientation");
    connect(orientation_changed, SIGNAL(clicked()),
            this, SLOT(onOrientationChangeClicked()));
    hbox->addWidget(orientation_changed);
    orientation_changed->show();

    QPushButton *close = new QPushButton("Close application");
    connect(close, SIGNAL(clicked()),
            qApp,  SLOT(quit()));
    hbox->addWidget(close);
    close->show();

    QTextEdit *te = d_ptr->text_entry;
    vbox->addWidget(te);
    te->show();
    te->setFocus();

    QSpacerItem *bottom_spacer = d_ptr->bottom;
    vbox->addItem(bottom_spacer);

    onShow();
}
コード例 #9
0
ファイル: tsp.cpp プロジェクト: danwa223/TDDD86
int main(int argc, char *argv[]) {

    QApplication a(argc, argv);

	// define 4 points forming a square
	Point p(100.0, 100.0);
	Point q(500.0, 100.0);
	Point r(500.0, 500.0);
	Point s(100.0, 500.0);
	// Set up a Tour with those four points
	// The constructor should link p->q->r->s->p
	Tour squareTour(p, q, r, s);
	squareTour.show();

    string filename = "tsp10.txt";
    ifstream input;
    input.open(filename);

    // get dimensions
    int width;
    int height;
    input >> width;
    input >> height;

    // setup graphical window
    QGraphicsView *view = new QGraphicsView();
    QGraphicsScene *scene = new QGraphicsScene();
    view->setScene(scene);
    view->scale(1, -1); //screen y-axis is inverted
    view->setSceneRect(0, 0, width, height);
    view->show();

    // run insertion heuristic
    Tour tour;
    double x;
    double y;
    while (input >> x >> y) {
        Point p(x, y);
		//tour.insertNearest(p);
        tour.insertSmallest(p);
        //uncomment the 4 lines below to animate
		tour.draw(scene);
		std::chrono::milliseconds dura(50);
		std::this_thread::sleep_for(dura);
		a.processEvents();
	}
    input.close();

    // print tour to standard output
    cout << "Tour distance: " << std::fixed << std::setprecision(4)
         << std::showpoint << tour.distance() << endl;
    cout << "Number of points: " << tour.size() << endl;
	tour.show();

    // draw tour
    tour.draw(scene);
	return a.exec(); // start Qt event loop
}
コード例 #10
0
void MainWindow::gotoScene(QGraphicsScene *scene){
    QGraphicsView *view = qobject_cast<QGraphicsView *>(centralWidget());
    view->setScene(scene);
    if(this->scene)
        this->scene->deleteLater();
    this->scene = scene;

    changeBackground();
}
コード例 #11
0
ファイル: widget.cpp プロジェクト: pTykvin/JNIx86Win32APITest
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{


    ui->setupUi(this);
    this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
    QGraphicsView *view = ui->graphicsView;
    view->setScene(&scene);

    view->setWindowFlags (Qt::FramelessWindowHint);
    view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    view->setRenderHint(QPainter::Antialiasing);

    view->setMaximumSize(size());
    view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    view->setCacheMode(QGraphicsView::CacheBackground);


    QGMenu *menu = new QGMenu(view->rect());
    //menu->setOpacity(0);
    scene.addItem(menu);

    int size = 152 + 16;

    for (int i = 0; i < 20 ;i++) {
        int r = i / 5;
        int c = i % 5;
        QGTile *tile = new QGTile;
        scene.addItem(tile);
        tile->moveBy(c * size,  r * size);
        tile->installSceneEventFilter(menu);
    }
    menu->setZValue(100);

//    QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);

//    QTimeLine *timer = new QTimeLine(5000);
//    timer->setFrameRange(0, 100);

//    QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
//    animation->setItem(ball);
//    animation->setTimeLine(timer);

//    for (int i = 0; i < 200; ++i)
//        animation->setPosAt(i / 200.0, QPointF(i, i));

//    scene.addItem(ball);

//    timer->start();

}
コード例 #12
0
void TimeGraphContainer::addGraphScene(GraphScene * scene) {
	scene->setTimeControl(time_widget->getTimeControl());

	QGraphicsView * v = new QGraphicsView();
	v->scale(1.0,-1.0); 
	v->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	v->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	list.append(v);
	v->setScene(scene); 
	inner_layout->addWidget(v);
	
}
コード例 #13
0
ファイル: main.cpp プロジェクト: Xambey/learning
int main (int argc, char** argv)
{
    QApplication app(argc, argv);

    QGraphicsView view;
    QGraphicsScene *scene = new QGraphicsScene(&view);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);

    Line *left, *right, *right2;

    int of = pos_x;

    for(int i = 0; i < c; i++)
    {
        Line* ball = new Line(QPoint(of, -2));
        scene->addItem(ball);
        of += size;
        if(i==0)
            left = ball;
        else if(i == c - 1)
            right = ball;
        else if(i == c - 2)
            right2 = ball;
    }

    QTimeLine *LeftTimerTo      = newAnim(left,0,45,QEasingCurve::OutQuart);
    QTimeLine *LeftTimerReturn    = newAnim(left,45,0,QEasingCurve::InQuart);
    QTimeLine *RightTimerTo     = newAnim(right,0,-45,QEasingCurve::OutQuart);
    QTimeLine *RightTimerBack   = newAnim(right,-45,0,QEasingCurve::InQuart);
    QTimeLine *RightTimerTo2     = newAnim(right2,0,-45,QEasingCurve::OutQuart);
    QTimeLine *RightTimerBack2   = newAnim(right2,-45,0,QEasingCurve::InQuart);



    scene->setSceneRect(0, 0, 940, 460);

    view.setCacheMode(QGraphicsView::CacheBackground);
    view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    view.setScene(scene);
    view.resize(960, 480);
    view.show();

    QObject::connect(LeftTimerTo,   SIGNAL(finished()), LeftTimerReturn,  SLOT(start()));
    QObject::connect(LeftTimerReturn, SIGNAL(finished()), RightTimerTo,   SLOT(start()));
    QObject::connect(LeftTimerReturn, SIGNAL(finished()), RightTimerTo2,   SLOT(start()));
    QObject::connect(RightTimerTo,  SIGNAL(finished()), RightTimerBack, SLOT(start()));
    QObject::connect(RightTimerTo2,  SIGNAL(finished()), RightTimerBack2, SLOT(start()));
    QObject::connect(RightTimerBack,SIGNAL(finished()), LeftTimerTo,    SLOT(start()));

    LeftTimerReturn->start();

    return app.exec();
}
コード例 #14
0
ファイル: test_main.cpp プロジェクト: aleixpol/GammaRay
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);

  // build data
  GVGraph *graph = new GVGraph("Graph");
  NodeId nid1 = graph->addNode("Node1");

  GraphId gid1 = graph->addGraph("SubGraph1");
  NodeId nid2 = graph->addNode("Node2", gid1);
  NodeId nid3 = graph->addNode("Node3", gid1);

  EdgeId eid1 = graph->addEdge(nid1, nid2, "Edge1");
  graph->setEdgeAttribute(eid1, "label", "Edge1");
  EdgeId eid2 = graph->addEdge(nid2, nid3, "Edge2");
  graph->setEdgeAttribute(eid2, "label", "Edge2");
  EdgeId eid3 = graph->addEdge(nid1, nid3, "Edge3");
  graph->setEdgeAttribute(eid3, "label", "Edge3");
  graph->applyLayout();

  if (argc > 1 && strcmp(argv[1], "--no-gui") == 0) {
    return 0;
  }

  // build ui
  QGraphicsView *view = new QGraphicsView;
  view->setRenderHint(QPainter::Antialiasing);
  QGraphicsScene *scene = new QGraphicsScene;
  view->setScene(scene);

  Q_FOREACH (const GVNodePair &pair, graph->gvNodes()) {
    const GVNode node = pair.second;
    QGraphicsItem *item = new GVNodeItem(node, 0);
    scene->addItem(item);
  }
  Q_FOREACH (const GVEdgePair &pair, graph->gvEdges()) {
    const GVEdge edge = pair.second;
    QGraphicsItem *item = new GVEdgeItem(edge, 0);
    scene->addItem(item);
  }
  Q_FOREACH (const GVSubGraphPair &pair, graph->gvSubGraphs()) {
    const GVSubGraph graph = pair.second;
    QGraphicsItem *item = new GVGraphItem(graph, 0);
    scene->addItem(item);
  }
  delete graph;
  graph = 0;

  view->show();

  return app.exec();
}
コード例 #15
0
ファイル: AboutWindow.cpp プロジェクト: jrmrjnck/cacheSim
// Constructor
AboutWindow::AboutWindow(QWidget *parent) : QDialog(parent)
{
   QGridLayout* layout = new QGridLayout( this );

   // Make the graphics view fixed size
   QGraphicsView* graphicsView = new QGraphicsView;
   graphicsView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
   graphicsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
   graphicsView->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );

   // Make the version text bold
   QLabel* appVersion = new QLabel( "Cache Simulator, Version 0.0.2" );
   QFont font;
   font.setPointSize( 10 );
   font.setBold( true );
   font.setWeight( 75 );
   appVersion->setFont( font );

   QLabel* descrip = new QLabel( HELP_TEXT );
   descrip->setWordWrap( true );

   QSpacerItem* vSpace = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding );

   // Add widgets to the layout
   layout->addWidget( graphicsView, 0, 0, 2, 1 );
   layout->addWidget( appVersion, 0, 2, 1, 1 );
   layout->addWidget( descrip, 1, 2, 1, 1 );
   layout->addItem( vSpace, 1, 1, 1, 1 );

   // Position a picture of Dr. Plassmann's head over his shoulders
   _plassHead = new QGraphicsPixmapItem;
   _plassHead->setPixmap( QPixmap("PlassHead.png") );
   _plassHead->setTransformOriginPoint( _plassHead->pixmap().width()/2,
                                        _plassHead->pixmap().height()/2 );
   _plassHead->setPos( 30, 8 );
   _angle = 0;

   // Tell the view which scene to show
   QGraphicsScene* scene = new QGraphicsScene;
   scene->addPixmap( QPixmap("PlassGround.png") );
   scene->addItem( _plassHead );
   graphicsView->setScene( scene );

   // Set a timer to rotate Dr. Plassmann's head every 20 ms
   _rotateTimer = new QTimer( this );
   connect( _rotateTimer, SIGNAL(timeout()), this, SLOT(rotateHead()) );
   _angle = 720;
   _rotateTimer->start( 20 );

   // Do not allow resizing
   setFixedSize( this->sizeHint() );
}
コード例 #16
0
void tst_qdeclarativelayoutitem::test_resizing()
{
    //Create Layout (must be done in C++)
    QGraphicsView view;
    QGraphicsScene scene;
    QGraphicsWidget *widget = new QGraphicsWidget();
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
    widget->setLayout(layout);
    scene.addItem(widget);
    view.setScene(&scene);
    //Add the QML snippet into the layout
    QDeclarativeEngine engine;
    QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/layoutItem.qml"));
    QDeclarativeLayoutItem* obj = static_cast<QDeclarativeLayoutItem*>(c.create());
    QVERIFY(obj);
    QCOMPARE(obj->minimumSize(), QSizeF(100,100));
    QCOMPARE(obj->preferredSize(), QSizeF(200,200));
    QCOMPARE(obj->maximumSize(), QSizeF(300,300));

    layout->addItem(obj);
    layout->setContentsMargins(0,0,0,0);
    widget->setContentsMargins(0,0,0,0);
    view.show();

    QVERIFY(obj!= 0);

    widget->setGeometry(QRectF(0,0, 400,400));
    QCOMPARE(obj->width(), 300.0);
    QCOMPARE(obj->height(), 300.0);

    widget->setGeometry(QRectF(0,0, 300,300));
    QCOMPARE(obj->width(), 300.0);
    QCOMPARE(obj->height(), 300.0);

    widget->setGeometry(QRectF(0,0, 200,200));
    QCOMPARE(obj->width(), 200.0);
    QCOMPARE(obj->height(), 200.0);

    widget->setGeometry(QRectF(0,0, 100,100));
    QCOMPARE(obj->width(), 100.0);
    QCOMPARE(obj->height(), 100.0);

    widget->setGeometry(QRectF(0,0, 40,40));
    QCOMPARE(obj->width(), 100.0);
    QCOMPARE(obj->height(), 100.0);

    widget->setGeometry(QRectF(0,0, 412,112));
    QCOMPARE(obj->width(), 300.0);
    QCOMPARE(obj->height(), 112.0);
}
コード例 #17
0
ファイル: main.cpp プロジェクト: dszoboszlay/qloud
// Entry point of the application
int main(int argc, char** argv)
{
  QApplication app(argc, argv);

  // FIXME: this is just a demo GUI
  CloudDef* cloudDef = CloudDef::create("priv/test1.ini");
  CloudGen cloudGen;
  QGraphicsView widget;
  widget.setScene(cloudGen.renderScene(*cloudDef, &widget));
  delete cloudDef;

  widget.show();
  return app.exec();
}
コード例 #18
0
ファイル: ptpsoctestjiginterface2.cpp プロジェクト: Qmax/PT6
void PTPSoCTestJigInterface2::enableRichGUI(){
	QWidget *m_objWidget=new QWidget(this);
	QGraphicsScene *entireScene = new QGraphicsScene(0,0,800,600);
	QGraphicsView  *entireView =  new QGraphicsView(m_objWidget);
	QPixmap obj1 = QPixmap(":/bg.png");
	QBrush obj2 = QBrush(obj1);
	obj2.setStyle(Qt::TexturePattern);
	obj2.setTexture(obj1);
	entireView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	entireView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	entireView->setFrameStyle(QFrame::Plain|QFrame::Sunken);
	entireView->setBackgroundBrush(obj2);
	entireView->setScene(entireScene);
	entireView->setGeometry(0,0,800,600);


	ui.groupBox_3->setParent(m_objWidget);
	ui.groupBox_4->setParent(m_objWidget);
	ui.groupBox_6->setParent(m_objWidget);
	ui.groupBox_7->setParent(m_objWidget);
	ui.groupBox_10->setParent(m_objWidget);
	ui.groupBox_11->setParent(m_objWidget);
	ui.groupBox_12->setParent(m_objWidget);
	ui.groupBox_13->setParent(m_objWidget);
	ui.groupBox_14->setParent(m_objWidget);
	ui.groupBox_15->setParent(m_objWidget);
	ui.label_9->setParent(m_objWidget);
    ui.comboBox_10->setParent(m_objWidget);
    ui.switchSRCIMP->setParent(m_objWidget);
    ui.switchFLY->setParent(m_objWidget);;

	ui.groupBox_3->setGeometry(10,10,161,70);
	ui.groupBox_4->setGeometry(180,10,161,71);
	ui.groupBox_6->setGeometry(350,10,161,70);
	ui.groupBox_7->setGeometry(10,180,771,211);
	ui.groupBox_10->setGeometry(10,90,391,80);
	ui.groupBox_11->setGeometry(420,90,151,80);
	ui.groupBox_12->setGeometry(590,90,191,80);
	ui.groupBox_13->setGeometry(590,200,170,61);
	ui.groupBox_14->setGeometry(520,10,261,70);
	ui.groupBox_15->setGeometry(10,400,321,80);
	ui.label_9->setGeometry(500,410,251,20);
    ui.comboBox_10->setGeometry(40,430,125,30);
    ui.switchSRCIMP->setGeometry(210,426,84,40);
    ui.switchFLY->setGeometry(350,426,111,40);

    m_objWidget->setStyleSheet("QLabel{color:white;}");

}
コード例 #19
0
bool  MainWindow::fileOpen()
{
    // get user to select filename and location
    QString filename = QFileDialog::getOpenFileName();
    if ( filename.isEmpty() ) return false;

    // open the file and check we can read from it
    QFile file( filename );
    if ( !file.open( QIODevice::ReadOnly ) )
    {
        showMessage( QString("Failed to open '%1'").arg(filename) );
        return false;
    }

    // open an xml stream reader and load simulation data
    QXmlStreamReader  stream( &file );
    Scene*            newScene = new Scene( m_undoStack );
    while ( !stream.atEnd() )
    {
        stream.readNext();
        if ( stream.isStartElement() )
        {
            if ( stream.name() == "qsimulate" )
                newScene->readStream( &stream );
            else
                stream.raiseError( QString("Unrecognised element '%1'").arg(stream.name().toString()) );
        }
    }

    // check if error occured
    if ( stream.hasError() )
    {
        file.close();
        showMessage( QString("Failed to load '%1' (%2)").arg(filename).arg(stream.errorString()) );
        delete newScene;
        return false;
    }

    // close file, display new scene, delete old scene, and display useful message
    file.close();
    m_undoStack->clear();
    QGraphicsView*   view = dynamic_cast<QGraphicsView*>( centralWidget() );
    view->setScene( newScene );
    delete m_scene;
    m_scene = newScene;
    showMessage( QString("Loaded '%1'").arg(filename) );
    return true;
}
コード例 #20
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    gameScene = new QGameScene();

    QGraphicsView *view = new QGraphicsView;
    view->setScene(gameScene);
    //view->show();

    setCentralWidget(view);

    setFixedSize(650, 432);
    setStatusBar(0);
}
コード例 #21
0
ファイル: main.cpp プロジェクト: Laetan/Zelda
int main( int argc, char **argv )
{
    QApplication app(argc, argv);
    QGraphicsView *view = new QGraphicsView();
    BasicScene *scene = new BasicScene(0,0,600,600,view);
    view->setScene(scene);

    // Instancier un objet Zelda



    view->show();

    return app.exec();

}
コード例 #22
0
void Ut_LockScreenStatusAreaView::testOrientationChangeUpdatesStatusBarGeometry()
{
    QGraphicsScene scene;
    QGraphicsView view;
    view.setScene(&scene);
    scene.addItem(statusArea);
    statusArea->setGeometry(QRectF(5, 10, 15, 20));
    m_subject->updateStatusBarGeometryProperty();

    testStatusBarGeometryProperty();

    // Setting the same geometry should do nothing
    m_subject->updateStatusBarGeometryProperty();
    QCOMPARE(xChangePropertyCallCount, 1);

    scene.removeItem(statusArea);
}
コード例 #23
0
ファイル: main.cpp プロジェクト: ganquan0910/qt5-demos
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QGraphicsScene *scene = new QGraphicsScene;
    scene->setSceneRect(QRectF(-200,-200,400,400));

    Butterfly *butterfly = new Butterfly;
    butterfly->setPos(-100,0);

    scene->addItem(butterfly);

    QGraphicsView *view = new QGraphicsView;
    view->setScene(scene);
    view->resize(450,450);
    view->show();

    return a.exec();
}
コード例 #24
0
void Ut_LockScreenStatusAreaView::testSetGeometryConnectsOrientationChangeSignal()
{
    QRectF geometry(0, 0, 15, 20);
    statusArea->setGeometry(geometry);
    QVERIFY(!disconnect(statusArea->sceneManager(), SIGNAL(orientationChangeFinished(M::Orientation)), m_subject, SLOT(updateStatusBarGeometryProperty())));
    QCOMPARE(xChangePropertyCallCount, 0);

    MSceneManager manager;
    mWidgetSceneManager = &manager;
    QGraphicsScene scene;
    QGraphicsView view;
    view.setScene(&scene);
    scene.addItem(statusArea);
    statusArea->setGeometry(geometry);
    QVERIFY(disconnect(statusArea->sceneManager(), SIGNAL(orientationChangeFinished(M::Orientation)), m_subject, SLOT(updateStatusBarGeometryProperty())));
    testStatusBarGeometryProperty();
    scene.removeItem(statusArea);
}
コード例 #25
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QGraphicsView gv;
    QGraphicsScene *scene = new QGraphicsScene(&gv);
    gv.setScene(scene);
    QGraphicsItem *rect = scene->addRect(0, 0, 200, 200, QPen(Qt::NoPen), QBrush(Qt::yellow));
    rect->setFlag(QGraphicsItem::ItemHasNoContents);
    rect->setFlag(QGraphicsItem::ItemClipsChildrenToShape);

    QGraphicsItem *childRect = scene->addRect(0, 0, 100, 100, QPen(Qt::NoPen), QBrush(Qt::red));
    childRect->setParentItem(rect);
    gv.show();
    MyObject o(rect);
    QMessageBox::information(0, "What you should see",
                             "The red rectangle should toggle visiblity, so you should see it flash on and off");
    return a.exec();
}
コード例 #26
0
ファイル: mainwindow.cpp プロジェクト: renc/coding_exercises
MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
{
    // create a scene with items,
    // use the view to show the scene
    QGraphicsScene *scene = new QGraphicsScene();
    QGraphicsView *gv = new QGraphicsView(this);
    gv->setScene(scene);
    if (gv->scene())
    {
        printf("renc: scene is not null.\n");

        // these two lines are at scene origin pos.
        scene->addLine(0, 0, 100, 0, QPen(Qt::red));
        scene->addLine(0, 0, 0, 100, QPen(Qt::green));

        /*QGraphicsRectItem *rect = */
        scene->addRect(QRectF(0,0,50,50), QPen(Qt::red), QBrush(Qt::green));

        // svg image
        QGraphicsSvgItem *svgItem = new QGraphicsSvgItem(svgFile2);
        scene->addItem((svgItem));
        svgItem->setPos(400, 0);
        bool rValid1 = svgItem->renderer()->isValid();
        printf("--%d--\n", rValid1);

        // QWidget to scene
        QPushButton *btn = new QPushButton("button 1");// at (0,0) by default.
        QGraphicsProxyWidget *btnWidget = scene->addWidget(btn);
        btnWidget->setPos(0, 400);

        //
        {
            SvgPushButton *btn2 = new SvgPushButton(svgFile1);
            QGraphicsProxyWidget *btnWidget2 = scene->addWidget(btn2);
            btnWidget2->setPos(400, 400);
        }
    }
    else
        printf("renc: scene is null.\n");

    //setCentralWidget(gv); setWindowTitle("Demo: graphics view");//QMainWindow
    setStyleSheet("background-color: rgb(100,120,50);");
}
コード例 #27
0
void MainWindow::on_search_clicked()
{
    //validate
    if(imageToSearch.isEmpty()) {
        ui->message->setText("Debe cargar una imagen para la búsqueda");
        return;
    }

    QSettings settings(SETTINGS_FNAME,QSettings::IniFormat);
    QString folder = settings.value("rootFolder",QVariant(".")).toString();

    ui->message->setText("detectando coincidencias");
    classifier.detect(imread(imageToSearch.toStdString().c_str()));
    QVector<QString> matches = classifier.getBestMatches();

    //mostrar resultados
    //limpiar
    QLayoutItem *wItem;

    while ((wItem = ui->resultsLayout->takeAt(0)) != 0) {
        ui->resultsLayout->removeItem(wItem);
        delete wItem;
    }
    //mostrar
    foreach(QString match, matches) {
        //show results
        QLabel* label = new QLabel;
        label->setText(match.toUpper());
        ui->resultsLayout->addWidget(label);

        QGraphicsView* graphics = new QGraphicsView;
        QGraphicsScene *scn = new QGraphicsScene( graphics );
        scn->setSceneRect(QRect(1,1,198,98));
        graphics->setScene( scn );
        graphics->setFixedSize(200, 100 );
        QPixmap pix( folder+QDir::separator()+match);
        scn->addPixmap( pix );
        ui->resultsLayout->addWidget(graphics);

        QSpacerItem* space = new QSpacerItem(100,20);
        ui->resultsLayout->addSpacerItem(space);

    }
コード例 #28
0
ファイル: main.cpp プロジェクト: ZkPrj/JQUIButton
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QGraphicsScene *scene = new QGraphicsScene();
    for (int i = 0; i < 100; ++i){
        JQUIButton* btn = new JQUIButton();
        btn->setFrame(QRectF(i/10*60, i%10*60, 50, 50));
        btn->setTitle("Hello");
        btn->setTitleAtStatus("张凯", JQUIButtonStatusNormal,QFont("宋体",14), QColor(Qt::blue));
        btn->setBgImg(new QPixmap("D:\\My_Project\\Resource\\image\\weixin_normal.png"));
        scene->addItem(btn);
    }

    QGraphicsView *view = new QGraphicsView();
    view->setScene(scene);
    view->show();

    return a.exec();
}
コード例 #29
0
ファイル: adhighaccuracy.cpp プロジェクト: Qmax/PT6
void ADHighAccuracy::enableRichGUI(){
	QWidget *m_objWidget=new QWidget(this);
	QGraphicsScene *entireScene = new QGraphicsScene(0,0,800,600);
	QGraphicsView  *entireView =  new QGraphicsView(m_objWidget);
	QPixmap obj1 = QPixmap(":/bg.png");
	QBrush obj2 = QBrush(obj1);
	obj2.setStyle(Qt::TexturePattern);
	obj2.setTexture(obj1);
	entireView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	entireView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	entireView->setFrameStyle(QFrame::Plain|QFrame::Sunken);
	entireView->setBackgroundBrush(obj2);
	entireView->setScene(entireScene);
	entireView->setGeometry(0,0,800,600);

	ui->groupBox->setParent(m_objWidget);
	ui->groupBox_2->setParent(m_objWidget);
	ui->groupBox_3->setParent(m_objWidget);
	ui->groupBox_57->setParent(m_objWidget);
	ui->groupBox_62->setParent(m_objWidget);
	ui->groupBox_63->setParent(m_objWidget);
	ui->groupBox_64->setParent(m_objWidget);
	ui->groupBox_65->setParent(m_objWidget);
	ui->groupBox_66->setParent(m_objWidget);
	ui->groupBox_67->setParent(m_objWidget);
//	ui->groupBox_68->setParent(m_objWidget);
	ui->GPCon->setParent(m_objWidget);
        ui->settings->setParent(m_objWidget);

	ui->groupBox->setGeometry(585,288,197,99);
	ui->groupBox_2->setGeometry(663,459,118,63);
	ui->groupBox_3->setGeometry(340,390,440,60);
	ui->groupBox_57->setGeometry(10,0,321,281);
	ui->groupBox_62->setGeometry(10,280,321,161);
        ui->groupBox_63->setGeometry(10,440,230,81);
	ui->groupBox_64->setGeometry(340,0,231,201);
	ui->groupBox_65->setGeometry(340,200,231,80);
	ui->groupBox_66->setGeometry(340,280,241,91);
	ui->groupBox_67->setGeometry(580,0,201,281);
//	ui->groupBox_68->setGeometry(320,450,341,71);
	ui->GPCon->setGeometry(320,450,341,71);
        ui->settings->setGeometry(240,450,70,70);
}
コード例 #30
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    createActions();                    	//创建主窗体的所有动作
    createMenus();                       	//创建主窗体的菜单栏

    scene = new QGraphicsScene;
    scene->setSceneRect(-200,-200,400,400);

    initScene();                         	//初始化场景

    QGraphicsView *view = new QGraphicsView;
    view->setScene(scene);
    view->setMinimumSize(400,400);
    view->show();

    setCentralWidget(view);
    resize(550,450);
    setWindowTitle(tr("Graphics Items"));
}