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. how to display background when all QTabWidgets are closed

how to display background when all QTabWidgets are closed

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 180 Views
  • 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.
  • B Offline
    B Offline
    Blackzero
    wrote on 10 Aug 2024, 16:51 last edited by
    #1

    How to display a background image when all tabs from QTabwidget are closed, for example like Visual studio code when all tabs are closed there is a background, is that possible?

    for example like this image when all tabs are closed there is a background image

    Screenshot 2024-08-10 235118.jpg

    J 1 Reply Last reply 10 Aug 2024, 17:24
    0
    • B Blackzero
      10 Aug 2024, 16:51

      How to display a background image when all tabs from QTabwidget are closed, for example like Visual studio code when all tabs are closed there is a background, is that possible?

      for example like this image when all tabs are closed there is a background image

      Screenshot 2024-08-10 235118.jpg

      J Offline
      J Offline
      JonB
      wrote on 10 Aug 2024, 17:24 last edited by JonB 8 Oct 2024, 17:25
      #2

      @Blackzero
      Did you try

      QTabWidget
      {
      background-image: url(:/img/background.png);
      }
      

      ?

      If that does not work (because QTabWidget is empty/has no tabs, or you don't want it when there are some tabs) more advanced discussion in https://forum.qt.io/topic/145432/how-to-set-the-qtabwidget-background-image-when-there-is-not-any-widget-page.

      B 1 Reply Last reply 10 Aug 2024, 21:02
      0
      • J JonB
        10 Aug 2024, 17:24

        @Blackzero
        Did you try

        QTabWidget
        {
        background-image: url(:/img/background.png);
        }
        

        ?

        If that does not work (because QTabWidget is empty/has no tabs, or you don't want it when there are some tabs) more advanced discussion in https://forum.qt.io/topic/145432/how-to-set-the-qtabwidget-background-image-when-there-is-not-any-widget-page.

        B Offline
        B Offline
        Blackzero
        wrote on 10 Aug 2024, 21:02 last edited by
        #3

        @JonB I modeled the code of Abderrahmene_Rayenein my own way, so every time I add a new tab I have to clear the setStyleSheet I don't know if this is efficient.

        void MainWindow::on_tabWidget_tabCloseRequested(int index)
        {
            ui->tabWidget->removeTab(index);
            if (ui->tabWidget->count() == 0)
            {
                ui->tabWidget->setStyleSheet("image: url(:/img/default.png);");
            }
            else
            {
                ui->tabWidget->setStyleSheet("");
            }
        }
        
        J 1 Reply Last reply 11 Aug 2024, 07:16
        0
        • B Blackzero
          10 Aug 2024, 21:02

          @JonB I modeled the code of Abderrahmene_Rayenein my own way, so every time I add a new tab I have to clear the setStyleSheet I don't know if this is efficient.

          void MainWindow::on_tabWidget_tabCloseRequested(int index)
          {
              ui->tabWidget->removeTab(index);
              if (ui->tabWidget->count() == 0)
              {
                  ui->tabWidget->setStyleSheet("image: url(:/img/default.png);");
              }
              else
              {
                  ui->tabWidget->setStyleSheet("");
              }
          }
          
          J Offline
          J Offline
          JonB
          wrote on 11 Aug 2024, 07:16 last edited by
          #4

          @Blackzero
          Seems reasonable to me. I don't know why you changed it to do it on QTabWidget::tabCloseRequested rather than QTabWidget::currentChanged or why you use image: rather than background-image: but doubtless these work for you.

          1 Reply Last reply
          0

          1/4

          10 Aug 2024, 16:51

          • Login

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