Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Graphicsview how to
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Graphicsview how to

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    toho71
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved