Qt World Summit: Register Today!

QLabel with specific options

  • Hello,

    I would like to have QLabel with gif. This label should be on the middle of the screen, can't move, can't resize, no have icon in the taskbar, no have X ( exit ) button and be on the top of this application.

    I have code:

        movie = new QMovie(R"(pathToGif)");
        label = new QLabel();
        label->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);

    And this code is almost perfect.
    This label is on the middle of screen ( it's not perfect middle but it's ok )
    I can't close this QLabel
    I can't move it
    I can't resize
    There is no icon on the task bar

    But this QLabel is on top of all applications ( for example when I open firefox - this QLabel is on top this firefox too ). I would like that this application would be only on top of my qt application.

    When I add a parent to QLabel I lose positioning ( center of the screen ).

  • Lifetime Qt Champion


    You can use QDesktopWidget to get the screen center.

  • @SGaist
    Thank you for answer, but screen center isn't problem ( my solution is good althought it isn't in the perfect center ).
    My main application Window has set maximum size to 300x300, so when I set parent to QLabel and I move main application Window I move QLabel too. I don't want it.

    My solution is good but it works on other ( not qt ) application too.

  • label = new QLabel(parentWidget, Qt::FramelessWindowHint | Qt::Tool);


    label = new QLabel();
    label->setParent(parentWidget, Qt::FramelessWindowHint | Qt::Tool);

    Also can use Qt::SplashScreen to replace Qt::FramelessWindowHint | Qt::Tool.

  • @Bonnie It works! Thank you Sir or Madame!

Log in to reply