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. QLabel with specific options
Forum Update on Tuesday, May 27th 2025

QLabel with specific options

Scheduled Pinned Locked Moved Solved General and Desktop
qlabelflags
5 Posts 3 Posters 814 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.
  • T Offline
    T Offline
    TomNow99
    wrote on last edited by TomNow99
    #1

    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);
        label->setMovie(movie);
        movie->start();
        label->show();
    

    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 ).

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

      Hi,

      You can use QDesktopWidget to get the screen center.

      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
      • T Offline
        T Offline
        TomNow99
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by Bonnie
          #4
          label = new QLabel(parentWidget, Qt::FramelessWindowHint | Qt::Tool);
          

          or

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

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

          1 Reply Last reply
          2
          • T Offline
            T Offline
            TomNow99
            wrote on last edited by
            #5

            @Bonnie It works! Thank you Sir or Madame!

            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