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. 2 video replacing button1 and button2 (Done-thanks)

2 video replacing button1 and button2 (Done-thanks)

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 918 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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by
    #1

    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();
    

    }
    @

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • H Offline
        H Offline
        houmingc
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

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

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          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