Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Iterazione tra QGraphicsVideoItem, QGraphicsScene, QGraphicsView
Qt 6.11 is out! See what's new in the release blog

Iterazione tra QGraphicsVideoItem, QGraphicsScene, QGraphicsView

Scheduled Pinned Locked Moved Unsolved Italian
1 Posts 1 Posters 719 Views
  • 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.
  • S Offline
    S Offline
    Sierra
    wrote on last edited by Sierra
    #1

    Buongiorno a tutti,

    per la prima volta da quando "frequento" il mondo Qt, mi sto interfacciando con il mondo delle scene e delle viste. Ho letto un po' di teoria, e ora sto facendo qualche esperimento per chiarirmi meglio come utilizzare il tutto.

    Ho creato questo semplice esempio:

    int main(int argc, char *argv[])
    {
        QApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
        QApplication a(argc, argv);
    
        QString url = "gst-pipeline: videotestsrc ! xvimagesink name=\"qtvideosink\"";
    
        QGraphicsVideoItem* item = new QGraphicsVideoItem;
        item->setSize(QSizeF(500, 480));
    
        QMediaPlayer p;
        p.setVideoOutput(item);
        p.setMedia(QMediaContent()); //discard
        p.setMedia(QUrl(url));
        p.play();
    
        QGraphicsScene* scene = new QGraphicsScene;
        QGraphicsRectItem *rect = scene->addRect( 10,10, 50, 70, QPen(Qt::black), QBrush(Qt::red));
        rect->setFlag(QGraphicsItem::ItemIsMovable);
    
        QGraphicsView view(scene);
        view.scene()->addItem(item);
        view.show();
    
        return a.exec();
    }
    

    Quello che ottengo però non è proprio come immaginavo:

    qtvideoitem.PNG

    Come potete vedere dall'immagine qui sopra, ottengo due finestre, una contenente View e Scene, ed una seconda contenente il VideoItem.
    Sapreste cortesemente dirmi che cosa/dove sto sbagliando?

    Versione Qt: 5.15.2, OS: Debian 12

    Grazie mille a tutti

    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