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. Integration of laout into gridlayout

Integration of laout into gridlayout

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

    Hi ! So here is my two problems :) I have a Marblemap, a videostream and a pushbutton on my windows.
    I placed them in the gridlayout. However when I resize the window, only the video resize, my marblemap doesn't expand too. I dont have the problem when my program is launched without the camera linked (so I only have a blackscreeen instead of my video).

    I would like to have my map resized in proportion with the videoplayer inside my window :)

    Here is my main where I integrate all layouts :)

    #include <QApplication>
    #include <QWidget>
    #include "mafenetre.h"
    #include <marble/MarbleWidget.h>
    #include <QGridLayout>
    #include <QFont>
    #include <QSplitter>
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
       
        // On crée le widget Marble via openstreet map
        Marble::MarbleWidget *mapWidget = new Marble::MarbleWidget;
        mapWidget->setProjection(Marble::Mercator);
        mapWidget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
        mapWidget->setWindowTitle("Test!");
        QWidget fenprincip;
        //fenprincip.setFixedSize(1600,900);
        MaFenetre *video= new MaFenetre;//(&fenprincip); le =New MaFenetre est là pour déclarer video en tant que widget pour le layout
        // Création du Layout Grid :
        QGridLayout *layout = new QGridLayout;
        QPushButton *switch_bouton = new QPushButton("Switch");
        switch_bouton->setFont(QFont("Comic Sans MS", 14));
        // Création des boites layout
        /*QVBoxLayout *videolayout = new QVBoxLayout;
        QHBoxLayout *maplayout = new QHBoxLayout;
        QVBoxLayout *switchLayout = new QVBoxLayout;*/
        /*//On met les Widget dedans
        videolayout->addWidget(video);//(x,y,hauteur,largeur)
        maplayout->addWidget(mapWidget);
        switchLayout->addWidget(m_bouton);
        mapWidget->sizePolicy();
        //Le redimensionnement auto ne marche pas sans trop de raison on va tenter avec une simple grille*/
       //On ajoute les widget à la grille
        layout->addWidget(video, 0,0,16,9);
        layout->addWidget(mapWidget,15,17,4,4);
        layout->addWidget(switch_bouton,14,17,1,4);
        // Connexion du clic du bouton à la fermeture de l'application
        QObject::connect(switch_bouton, SIGNAL(clicked()), video, SLOT(quit()));
       
        fenprincip.show();
        return app.exec();
    }
    

    Also my cpp file :

    #include "mafenetre.h"
    #include <QGraphicsScene>
    #include <QGraphicsView>
    #include <QGraphicsVideoItem>
    #include <QDebug>
    MaFenetre::MaFenetre(QWidget *parent) :
        QWidget(parent)
    {
        //QString fichier = QCoreApplication::applicationDirPath() + QString("/test.mpg");
        qDebug() << QUrl("rtsp://ednded:sokzd@169.254.xxx.xx/axis-media/media.amp");
        player = new QMediaPlayer;
        player->setMedia(QUrl("rtsp://ednded:sokzd@169.254.xxx.xx/axis-media/media.amp"));
        // GUI 1
        QVBoxLayout *layoutPrincipal = new QVBoxLayout;
        videoWidget = new QVideoWidget(this);
        layoutPrincipal->addWidget(videoWidget);
        player->setVideoOutput(videoWidget);
        setLayout(layoutPrincipal);
        setWindowTitle(QString::fromUtf8("player"));
        //setFixedWidth(960);
        //setFixedHeight(540);
        connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(stateChanged(QMediaPlayer::State)));
        connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
        connect(player, SIGNAL(metaDataChanged(const QString &, const QVariant &)), this, SLOT(metaDataChanged(const QString &, const QVariant &)));
        connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(error(QMediaPlayer::Error)));
        player->play();
    }
    MaFenetre::~MaFenetre()
    {
    }
    void MaFenetre::stateChanged(QMediaPlayer::State state)
    {
        qDebug() << Q_FUNC_INFO << state;
        if (state == QMediaPlayer::StoppedState)
        {
            videoWidget->update();
        }
    }
    void MaFenetre::metaDataChanged()
    {
        qDebug() << player->availableMetaData();
        if (player->isMetaDataAvailable())
        {
            qDebug() << player->metaData(QMediaMetaData::Title).toString();
            qDebug() << player->metaData(QMediaMetaData::Size);
            qDebug() << player->metaData(QMediaMetaData::Duration);
            qDebug() << player->metaData(QMediaMetaData::Resolution);
        }
    }
    void MaFenetre::metaDataChanged(const QString &key, const QVariant &value)
    {
        //"AudioBitRate", "AudioCodec", "PixelAspectRatio", "Resolution", "VideoCodec"
        if(key == "AudioCodec")
            qDebug() << key << value;
        if(key == "VideoCodec")
            qDebug() << key << value;
        if(key == "Resolution")
            qDebug() << key << value;
    }
    void MaFenetre::error(QMediaPlayer::Error error)
    {
        qDebug() << Q_FUNC_INFO << player->errorString() << error;
    }
    

    Thanks for helping me :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From the looks of it, you are trying to set your grid layout on your MaFenetre object which already has a layout which should give you an error message.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • C Offline
        C Offline
        Chanchan
        wrote on last edited by
        #3

        @SGaist Thanks for your answer :)

        Oh sorry I forgot to delete the part (&fenprincip) (I modified my code but the problem is still here) :/

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Chanchan
          wrote on last edited by
          #4

          So I solved my problem by fixing all my coloumns with a setColumnSize :) Now everythings has the good place !

          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