[SOLVED]Graphicsview how to



  • Hello
    I'm trying to use the graphicsview and graphics scene.
    Only a simpel test to build from but even this doesn't work

    I use qt desigener and puts the g_view on the mainwindow and I'm trying to set the scene in the constructor.

    But nothing happens.
    Here is some code.

    @m_graphScen = new QGraphicsScene(this);
    m_graphScen->setSceneRect(0,0,790,290);
    m_graphScen->addText("Hello, world!");
    // a blue background
    m_graphScen->setBackgroundBrush(Qt::blue);

    // a gradient background
    QRadialGradient gradient(0, 0, 10);
    gradient.setSpread(QGradient::RepeatSpread);
    m_graphScen->setBackgroundBrush(gradient);
    
    QPainterPath path;
    path.moveTo(10, 30);
    path.cubicTo(80, 0, 50, 50, 80, 80);
    
    m_graphScen->addPath(path, QPen(Qt::black), QBrush(Qt::green));
    
    m_graphScen->addText("Hello, world!", QFont("Times", 10, QFont::Bold));
    
    
    ui->m_graphView->setFixedSize(800,300);
    ui->m_graphView->setScene(m_graphScen);
    ui->m_graphView->setBackgroundBrush(Qt::blue);
    

    @

    The problem wasn't here.
    It was the calling to this method that was the problem


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.