2 video replacing button1 and button2 (Done-thanks)



  • Video code below is working and i don't know how to create two video side by side,
    replacing button1 and button2. How to layout->addwidget(videowidget) instead addwidget(button1)

    @
    ui->setupUi(this);
    QWidget *window= new QWidget;
    window->setWindowTitle("My App");

    QLabel *label= new QLabel("Hello");
    QPushButton *button1 = new QPushButton("button1");
    QPushButton *button2 = new QPushButton("button2");
    QGridLayout *layout= new QGridLayout;
    
    layout->addWidget(button1,0,0);
    layout->addWidget(button2,0,1);
    layout->addWidget(label,1,0,1,2);
    video();
    window->setLayout(layout);
    window->show();
    

    @

    @
    void MainWindow::video()
    {
    playlist= new QMediaPlaylist();
    player= new QMediaPlayer;
    videoWidget = new QVideoWidget;

    playlist->addMedia(QUrl::fromLocalFile("/home/ubuntu/Desktop/hotgirl.mp4"));
    player->setPlaylist(playlist);
    
    player->setVideoOutput(videoWidget);
    videoWidget->show();
    playlist->setCurrentIndex(1);
    player->play();
    

    }
    @


  • Moderators

    A possibility would be to use QStackedWidget. Or to simply add the video widget and the button side by side and set only 1 of them visible.
    Invisible widgets don't use any space in the layout by default.



  • sorry for my unclear writting.
    I meant how to layout->addwidget(videowidget) instead addwidget(button1)


  • Moderators

    i don't know if thats clearer :D
    Whats wrong with layout->addWidget(videowidget) ??


Log in to reply
 

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