Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Full screen mode is not being shown when signal is emitted



  • Here is my simple program to emit a signal and connect it to a slot. Here the signal emitted is making the label invisible with the signal name

    invLabel
    

    and the slot i have is reveal in which one will set the label visible and emit the signal invLabel when the label is visible.

    But the problem is when the signal got emitted, I am using an inbuilt slot called showFullScreen() which is not working.

    Here is the code for your reference.
    s_s.cpp file

    #include "s_s.h"
    
    s_s::s_s() : QWidget ()
    {
        setFixedSize(300,150);
        Button1 = new QPushButton("Reveal",this);
        Button1->move(60,70);
    //    connect(Button1,SIGNAL(clicked()),qApp,SLOT(quit()));
        label = new QLabel("Here is your text", this);
        label->setVisible(false);
        QObject::connect(Button1,SIGNAL(clicked()),this,SLOT(reveal()));
        connect(this,SIGNAL(invLabel()),this,SLOT(showFullScreen()));
    }
    
    void s_s::reveal()
    {
        label->setVisible(true);
        if(label->isVisible())
        {
            emit invLabel();
        }
    }
    
    

    s_s.h file

    #ifndef S_S_H
    #define S_S_H
    
    #include <QApplication>
    #include <QtWidgets>
    
    class s_s : public QWidget
    {
        Q_OBJECT
    public:
        s_s();
    
    public slots:
        void reveal();
    
    signals:
        void invLabel();
    
    private:
        QPushButton *Button1;
        QLabel *label;
    };
    
    
    #endif // S_S_H
    
    

    and main.cpp file

    #include <QApplication>
    #include "s_s.h"
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc,argv);
        s_s MyTest;
        MyTest.show();
        return app.exec();
    }
    
    

    It would be nice, if i know where am i going wrong.


  • Moderators

    Are you sure the connect statements work? They return true on success - check it.

    Also, use new signal slot syntax, it will catch errors at compile time.



  • @JennyAug13 said in Full screen mode is not being shown when signal is emitted:

    connect(this,SIGNAL(invLabel()),this,SLOT(showFullScreen()));

    Sorry if I missing something, but if you posted all your code I cannot see where method showFullScreen() is declared to be a slot...

    I agree that you may need to use the new syntax for connecting signals and slots, it provides compile time support for errors.


  • Moderators

    @Pablo-J.-Rogina said in Full screen mode is not being shown when signal is emitted:

    @JennyAug13 said in Full screen mode is not being shown when signal is emitted:

    connect(this,SIGNAL(invLabel()),this,SLOT(showFullScreen()));

    Sorry if I missing something, but if you posted all your code I cannot see where method showFullScreen() is declared to be a slot...

    It's in QWidget http://doc.qt.io/qt-5/qwidget.html#showFullScreen



  • @sierdzio my bad then. Thank you for the clarification.



  • What is your OS ?
    This code runs ok on a Windows system, but not linux.
    The docs for showFullScreen indicate that there are problems on X11 systems, and you may have to fiddle with window flags to get it to work,
    ok: on Linux it will work if you remove the line:

    setFixedSize(300,150);
    


  • @mranger90 I am working on ubuntu in a virtual box



  • @mranger90 Yes, it works if i remove the line said by you. Thanks alot :)



  • Why dont it work if we set a fixed size? Is it same case in windows also? Will that not work on windows also?



  • @JennyAug13 Having the setFixedSize call in Windows does work. The window will be shown in full screen mode when the invLabel signal is emitted.
    It is only on my linux system (which btw is also Ubuntu 18.04 running in a VM) that the window will not change to full screen.
    As to why ? Don't know for sure. A quick look at the QWidget sources doesn't reveal much.
    I'm guessing that setFixedSize() enables some constraint flags that linux interprets as "never change the size" while Windows is a bit more lax.


Log in to reply