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. Setting a translucent background to current widget of QStackedWidget
Forum Updated to NodeBB v4.3 + New Features

Setting a translucent background to current widget of QStackedWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 448 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.
  • W Offline
    W Offline
    walle19
    wrote on 23 Feb 2021, 14:09 last edited by walle19
    #1

    Hi All,

    Platform: Linux Kubuntu 14
    QT Version: 4.7.1

    I am interested in using a busy indicator spinner when long processing is performed
    moving between a QStackedWidget pages.

    For example, I defined QStackWidget with three pages. One of them is a page that displays a busy indicator spinner.
    When moving from page1 to page2 some processing is performed and for the period of time it takes I want to display the busy indicator with translucent background. I tried this but no success:

    spinner->setAttributes(Qt::TranslucentBackground, true) 
    

    My question is - Can I make the background of the spinner widget translucent so that when it is displayed (and spinning) it will show in the background the last page or widget I was at.
    To make clear - When moving from page1 to page2 , show spinner on top of page1 but keep the spinners background translucent so we still see page1. When processing finishes show page2.

    void on_moveFrom1to2_clicked() {
    stackedWidget->setCurrentWidget(spinner)
    processing()
    stackedWidget->setCurrentWidget(page2)
    }
    

    If this approach is wrong I would appreciate any suggestions

    Thanks for the help

    B 1 Reply Last reply 24 Feb 2021, 02:57
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 23 Feb 2021, 19:00 last edited by mrjj
      #2

      Hi
      Is the actual spinner GIF image transparent?

      It should be possible to overlay it but not sure what part is missing.
      Update: Bonnie made me realize what you really asking and only one page is visible
      at a time so you have to overlay the spinner to the current page.

      I used this overlay widget
      https://stackoverflow.com/questions/19199863/draw-rectangular-overlay-on-qwidget-at-click

      You might want to remove
      setAttribute(Qt::WA_TransparentForMouseEvents);
      so it will eat any mouse clicks.

      1 Reply Last reply
      0
      • W walle19
        23 Feb 2021, 14:09

        Hi All,

        Platform: Linux Kubuntu 14
        QT Version: 4.7.1

        I am interested in using a busy indicator spinner when long processing is performed
        moving between a QStackedWidget pages.

        For example, I defined QStackWidget with three pages. One of them is a page that displays a busy indicator spinner.
        When moving from page1 to page2 some processing is performed and for the period of time it takes I want to display the busy indicator with translucent background. I tried this but no success:

        spinner->setAttributes(Qt::TranslucentBackground, true) 
        

        My question is - Can I make the background of the spinner widget translucent so that when it is displayed (and spinning) it will show in the background the last page or widget I was at.
        To make clear - When moving from page1 to page2 , show spinner on top of page1 but keep the spinners background translucent so we still see page1. When processing finishes show page2.

        void on_moveFrom1to2_clicked() {
        stackedWidget->setCurrentWidget(spinner)
        processing()
        stackedWidget->setCurrentWidget(page2)
        }
        

        If this approach is wrong I would appreciate any suggestions

        Thanks for the help

        B Offline
        B Offline
        Bonnie
        wrote on 24 Feb 2021, 02:57 last edited by Bonnie
        #3

        @walle19
        Yes your approach is wrong.
        You shouldn't define the spinner as a page because in QStackedWidget when you switch to one page, others will be hidden.
        Even the background is translucent you still won't see other pages.
        Just create it as a child widget of QStackedWidget (or any parent widget) and control the geometry and visibility yourself.
        And another thing to mention, will your processing() function block the main thread? If it will then the spinner may be not shown properly.

        1 Reply Last reply
        1

        1/3

        23 Feb 2021, 14:09

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved