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. How to Fullscreen mode
Forum Updated to NodeBB v4.3 + New Features

How to Fullscreen mode

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 38.7k 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.
  • podsvirovP Offline
    podsvirovP Offline
    podsvirov
    wrote on last edited by
    #6

    Image not available:

    !http://nw0.upanh.com/b5.s36.d2/9296d18d72866babf8aad86fd594bef3_55083090.screenshotat20130424000811.png(What is this?)!

    Give code MyCameraWindow class.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      diepa9k39
      wrote on last edited by
      #7

      Here is code MyCameraWindow.h
      @
      #ifndef MYCAMERAWINDOW_H_
      #define MYCAMERAWINDOW_H_

      #include <QWidget>
      #include <QVBoxLayout>
      #include "QOpenCVWidget.h"
      #include <opencv/cv.h>
      #include <opencv/highgui.h>

      class MyCameraWindow : public QWidget
      {
      Q_OBJECT
      private:
      QOpenCVWidget *cvwidget;
      CvCapture *camera;

      public:
          MyCameraWindow(CvCapture *cam, QWidget *parent=0);
           
      protected:
          void timerEvent(QTimerEvent*);        
      

      };

      #endif /MYCAMERAWINDOW_H_/

      @

      Here is code MyCameraWindow.cpp
      @

      #include "MyCameraWindow.h"

      MyCameraWindow::MyCameraWindow(CvCapture *cam, QWidget *parent) : QWidget(parent) {
      camera = cam;
      QVBoxLayout *layout = new QVBoxLayout;
      cvwidget = new QOpenCVWidget(this);
      layout->addWidget(cvwidget);
      setLayout(layout);
      resize(500, 400);

      startTimer(100);  // 0.1-second timer
      

      }

      void MyCameraWindow::timerEvent(QTimerEvent*) {
      IplImage *image=cvQueryFrame(camera);
      cvwidget->putImage(image);
      }

      @
      [quote author="Konstantin Podsvirov" date="1366802481"]Image not available:

      !http://nw0.upanh.com/b5.s36.d2/9296d18d72866babf8aad86fd594bef3_55083090.screenshotat20130424000811.png(What is this?)!

      Give code MyCameraWindow class.[/quote]

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on last edited by
        #8

        @diepa9k39

        Did you try with setting the windowFlag and windowState ?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          diepa9k39
          wrote on last edited by
          #9

          I don't understand!
          [quote author="Sam" date="1366866064"]@diepa9k39

          Did you try with setting the windowFlag and windowState ?[/quote]

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on last edited by
            #10

            In the above posts I have provide few links that deals with the same issue. Inside the constructor of MyCameraWindow you can set the windowFlag and windowState eg.

            @setWindowFlags(widget->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);

            setWindowState(widget->windowState() | Qt::WindowFullScreen);@

            1 Reply Last reply
            0
            • D Offline
              D Offline
              diepa9k39
              wrote on last edited by
              #11

              I want to resize window and frame resize too. Can you help me?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Sam
                wrote on last edited by
                #12

                Yes we can help, first of all the images that you attached are not displayed. Kindly update the image links so that it is easy to understand your requirement.

                If you are adding your widgets to a layout then the resizing should be handled automatically, you can also set the sizePolicy for your frame.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  diepa9k39
                  wrote on last edited by
                  #13

                  Link of Image is working!

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Sam
                    wrote on last edited by
                    #14

                    Sorry, the images are not visible to me may be the image site is banned at my current location. Can you post the direct link to the images where it is hosted.

                    1 Reply Last reply
                    0
                    • podsvirovP Offline
                      podsvirovP Offline
                      podsvirov
                      wrote on last edited by
                      #15

                      Wrote a small filter that fits Q[V|H]BoxLayout classes.

                      Use double click to reveal the element on the full screen.
                      Use {Esc} to return to the layout.

                      QFullScreenFilter.pro:

                      @
                      QT += core gui

                      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                      TARGET = QFullScreenFilter
                      TEMPLATE = app

                      SOURCES += main.cpp
                      QFullScreenFilter.cpp

                      HEADERS +=
                      QFullScreenFilter.hpp
                      @

                      main.cpp:

                      @
                      #include "QFullScreenFilter.hpp"
                      #include <QApplication>
                      #include <QLabel>
                      #include <QVBoxLayout>

                      QLabel* createLabel(const QString &text)
                      {
                      QLabel *label = new QLabel(text);
                      label->setAlignment(Qt::AlignCenter);
                      label->setFrameStyle(QFrame::Panel | QFrame::Raised);
                      label->setLineWidth(2);
                      return label;
                      }

                      int main(int argc, char *argv[])
                      {
                      QApplication app(argc, argv);

                      QWidget widget;
                      
                      QFullScreenFilter *filter = new QFullScreenFilter(&widget);
                      
                      QVBoxLayout *box = new QVBoxLayout();
                      box->setMargin(20);
                      
                      for (int i = 0; i < 3; i++) {
                          QLabel *label = createLabel(QString("Content %1").arg(i + 1));
                          label->installEventFilter(filter);
                          box->addWidget(label);
                      }
                      
                      widget.setLayout(box);
                      widget.resize(200, 60 * box->count());
                      widget.show();
                      
                      return app.exec&#40;&#41;;
                      

                      }
                      @

                      QFullScreenFilter.hpp:

                      @
                      #ifndef QFULLSCREENFILTER_HPP
                      #define QFULLSCREENFILTER_HPP

                      #include <QObject>
                      #include <QLayout>
                      #include <QMap>

                      class QFullScreenFilter : public QObject
                      {
                      Q_OBJECT
                      public:
                      explicit QFullScreenFilter(QObject *parent = 0);

                      bool eventFilter(QObject *watched, QEvent *event&#41;;
                      

                      private:
                      bool showFullScreen(QWidget *widget);
                      bool showNormal(QWidget *widget);

                      struct Attribute {
                          Attribute() : layout(0), index(-1) {}
                          operator bool () { return layout && index >= 0; }
                          QLayout *layout;
                          int index;
                      };
                      Attribute& getAttribute(QWidget *widget);
                      QMap<QWidget*, Attribute> attributes;
                      

                      };

                      #endif // QFULLSCREENFILTER_HPP
                      @

                      QFullScreenFilter.cpp:

                      @
                      #include "QFullScreenFilter.hpp"

                      #include <QWidget>
                      #include <QBoxLayout>
                      #include <QMouseEvent>

                      QFullScreenFilter::QFullScreenFilter(QObject *parent) :
                      QObject(parent)
                      {
                      }

                      bool QFullScreenFilter::eventFilter(QObject *watched, QEvent event)
                      {
                      if (QWidget widget = qobject_cast<QWidget>(watched))
                      {
                      switch (event->type()) {
                      case QEvent::MouseButtonDblClick:
                      if (showFullScreen(widget)) return true;
                      break;
                      case QEvent::KeyPress:
                      if (static_cast<QKeyEvent
                      >(event)->key() == Qt::Key_Escape) {
                      if (showNormal(widget)) return true;
                      }
                      break;
                      default:
                      break;
                      }
                      }
                      return QObject::eventFilter(watched, event);
                      }

                      bool QFullScreenFilter::showFullScreen(QWidget *widget)
                      {
                      if (Attribute &a = getAttribute(widget)) {
                      a.layout->removeWidget(widget);
                      widget->setParent(0);
                      widget->showFullScreen();
                      return true;
                      }
                      return false;
                      }

                      bool QFullScreenFilter::showNormal(QWidget *widget)
                      {
                      if (Attribute &a = getAttribute(widget)) {
                      if (QBoxLayout box = qobject_cast<QBoxLayout>(a.layout)) {
                      box->insertWidget(a.index, widget);
                      } else {
                      a.layout->addWidget(widget);
                      }
                      return true;
                      }
                      return false;
                      }

                      QFullScreenFilter::Attribute& QFullScreenFilter::getAttribute(QWidget *widget)
                      {
                      Attribute& a = attributes[widget];
                      QWidget *parent = widget ? widget->parentWidget() : 0;
                      if (!a && parent) {
                      a.index = (a.layout = parent->layout()) ? a.layout->indexOf(widget) : -1;
                      }
                      return a;
                      }
                      @

                      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