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. QTool Dialog with OpenGL Stuff in Qt 5.5
Forum Updated to NodeBB v4.3 + New Features

QTool Dialog with OpenGL Stuff in Qt 5.5

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.7k Views 2 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.
  • S Offline
    S Offline
    stvokr
    wrote on last edited by stvokr
    #1

    Hi all,

    I have a problem with QTool dialogs and OpenGL using Qt 5.5. I noticed that this OpenGL-widgets-thing has been updated in Qt 5.4.
    So I think my problem has something to do with these updates.

    I am using Windows 7 64Bit with NVidia Geforce 840M, 8GB Ram, Qt 5.5 and Qt 5.3.2 with Qt Creator and Visual Studio 2010 Compiler.

    I have reduced my program to a simple program which has the same problem.
    I have a QTool dialog with shows some OpenGL stuff.
    Now the bevavior of switching to fullscreen differs to Qt 5.3.2 as follows:

    1. the screen is flickering, it does not in Qt 5.3.2.
    2. the QTool dialog seems to be hidden, but when you click one the last dialog's position (where it was before) the screen is flickering again and the dialog is visible in front of the mainwindow. Clicking on the mainwindow again hides the dialog again (with flickering).
    3. the menubar has a similar behavior as the dialog. It is not visible but it is there, you can click on actions and they will be triggered. But you don't see any submenus or actions.

    This OpenGL dialog is working if it is a normal and not a QTool Dialog.
    Strange things going on there. Any ideas, explanations, suggestions, comments?

    My Code:

    main.cpp is default contructed by Qt Creator.
    mainwindow.ui is default contructed by Qt Creator.

    mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    #if QT_VERSION >= QT_VERSION_CHECK( 5, 4, 0 )
    #include <QtWidgets>
    #else
    #include <QGLWidget>
    #endif
    
    #if QT_VERSION >= QT_VERSION_CHECK( 5, 4, 0 )
    class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
    #else
    class GLWidget : public QGLWidget
    #endif
    {
        Q_OBJECT
    
    public:
        explicit GLWidget( QWidget* parent = 0 );
        ~GLWidget() {}
    };
    
    // -------------------------
    
    namespace Ui {
        class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow( QWidget* parent = 0 );
        ~MainWindow();
    
    public slots:
        void onClicked();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
    

    mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    #include <QDialog>
    #include <QGridLayout>
    #include <QLabel>
    
    // -------------------------
    
    GLWidget::GLWidget( QWidget* parent )
    #if QT_VERSION >= QT_VERSION_CHECK( 5, 4, 0 )
        : QOpenGLWidget( parent )
        , QOpenGLFunctions()
    #else
        : QGLWidget( parent )
    #endif
    {
    }
    
    // -------------------------
    
    MainWindow::MainWindow( QWidget* parent ) :
        QMainWindow( parent ),
        ui( new Ui::MainWindow )
    {
        ui->setupUi( this );
    
        QPushButton* pb = new QPushButton( "Fullscreen", this );
        connect( pb, SIGNAL( clicked() ), this, SLOT( onClicked() ) );
        QGridLayout* layout = new QGridLayout( ui->centralWidget );
        layout->addWidget( pb );
    
        QMenuBar* menuBar = new QMenuBar( this );
        QMenu* fileMenu = menuBar->addMenu( "File" );
        fileMenu->addAction( "Quit", this, SLOT( close() ) );
        setMenuBar( menuBar );
    
        QDialog* myDialog = new QDialog( this );
    
        QGridLayout* gridLayout = new QGridLayout( myDialog );
        gridLayout->setMargin( 0 );
        gridLayout->addWidget( new GLWidget( myDialog ) );
    
        // remove to keep it work as normal dialog
        myDialog->setWindowFlags( Qt::Tool );
    
        myDialog->resize( 200, 200 );
        myDialog->show();
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::onClicked()
    {
        if( isFullScreen() )
            showNormal();
        else
            showFullScreen();
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I'd recommend checking with the current 5.6 beta to see if you are still experiencing the same stuff, if so, please take a look at the bug report system to see if something known. If not please consider opening a new report providing your example as a minimal compilable project.

      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
      0
      • kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by kshegunov
        #3

        Hello,
        Your problem is probably related to QTBUG-41309 (similar to QTBUG-7556). I stumbled upon those two recently when I was trying to show a main window containing a QOpenGLWidget in full screen. You could try this workaround by putting it in your QWidget::showEvent override:

        void YourWidget::showEvent(QShowEvent * event)
        {
        	event->accept();
        	// Handle maximize/restore
        	...
        	// Workaround for QTBUG-41309, we want the window maximized
        	QRect geometry = QApplication::desktop()->screenGeometry();
        	setGeometry(geometry);
        	setFixedSize(geometry.width(), geometry.height() + 1);
        }
        

        I hope this helps.
        Kind regards.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1
        • S Offline
          S Offline
          stvokr
          wrote on last edited by
          #4

          Hello

          this kind of a "pseudo fullscreen" helped.
          But I didn't solve it with the showEvent, because showFullScreen() does not enter showEvent() when the window is already shown.
          I used a button (and an action) to switch to fullscreen and back to normal view, so this is how I do it. And that works for me, thankx.
          And it's not even flickering. :-)

          void MainWindow::onClicked()
          {
              if( m_fullscreen )
              {
                  m_fullscreen = false;
          
                  setMinimumSize( 0, 0 );
                  setMaximumSize( 16777215, 16777215 );
                  setGeometry( m_defaultGeometry );
          
                  showNormal();
              }
              else
              {
                  m_fullscreen = true;
          
                  m_defaultGeometry = geometry();
          
                  QRect rectGeometry = QApplication::desktop()->screenGeometry();
                  setGeometry( rectGeometry );
                  setFixedSize( rectGeometry.width(), rectGeometry.height() + 1 );
              }
          }
          
          kshegunovK 1 Reply Last reply
          0
          • S stvokr

            Hello

            this kind of a "pseudo fullscreen" helped.
            But I didn't solve it with the showEvent, because showFullScreen() does not enter showEvent() when the window is already shown.
            I used a button (and an action) to switch to fullscreen and back to normal view, so this is how I do it. And that works for me, thankx.
            And it's not even flickering. :-)

            void MainWindow::onClicked()
            {
                if( m_fullscreen )
                {
                    m_fullscreen = false;
            
                    setMinimumSize( 0, 0 );
                    setMaximumSize( 16777215, 16777215 );
                    setGeometry( m_defaultGeometry );
            
                    showNormal();
                }
                else
                {
                    m_fullscreen = true;
            
                    m_defaultGeometry = geometry();
            
                    QRect rectGeometry = QApplication::desktop()->screenGeometry();
                    setGeometry( rectGeometry );
                    setFixedSize( rectGeometry.width(), rectGeometry.height() + 1 );
                }
            }
            
            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @stvokr
            Sure, you could use the code where appropriate, it's not needed to be in the show event exactly. Glad it worked, it took me some time to obtain that precious information, so I gladly disseminate it further ;)

            Read and abide by the Qt Code of Conduct

            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