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. set background for mainwindow and set background color for widgets are coonfused in css.
Qt 6.11 is out! See what's new in the release blog

set background for mainwindow and set background color for widgets are coonfused in css.

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 3 Posters 7.6k Views 2 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.
  • m.sueM Offline
    m.sueM Offline
    m.sue
    wrote on last edited by
    #9

    Hi,
    you @MhM93 use background-image but @raven-worx proposes to use background. Maybe this is essential.
    -Michael.

    1 Reply Last reply
    0
    • MhM93M Offline
      MhM93M Offline
      MhM93
      wrote on last edited by
      #10

      Hi,
      @raven-worx , thanks for reply.

      qDebug() << QFile::exists(":/myImg/1.jpg");
      

      this code return true;
      @m-sue : thanks for reply. I change my code to this. but the picture is not set the background in mainwindow:

      QWidget , QDialog
      {
      	background-color:rgb(67,67,67);
      }
      
      #MainWindow
      {
      	background: url(:/myImg/1.jpg);
      }
      

      H.Ghassami

      raven-worxR 1 Reply Last reply
      0
      • MhM93M MhM93

        Hi,
        @raven-worx , thanks for reply.

        qDebug() << QFile::exists(":/myImg/1.jpg");
        

        this code return true;
        @m-sue : thanks for reply. I change my code to this. but the picture is not set the background in mainwindow:

        QWidget , QDialog
        {
        	background-color:rgb(67,67,67);
        }
        
        #MainWindow
        {
        	background: url(:/myImg/1.jpg);
        }
        
        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #11

        @MhM93
        and now pls try to set it exactly to this:

        QWidget , QDialog
        {
        	background: rgb(67,67,67);
        }
        
        #MainWindow
        {
        	background: url(':/myImg/1.jpg');
        }
        

        But most probably you wont see the image because you set it to the main window directly. And it's central widget is covering over it, since you also set a background color for all QWidgets.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • MhM93M Offline
          MhM93M Offline
          MhM93
          wrote on last edited by MhM93
          #12

          really thanks @raven-worx for reply. I change the css to this:

          QWidget , QDialog
          {
          	background:rgb(67,67,67);
          }
          
          #MainWindow
          {
          	background: url(:/myImg/1.jpg);
          }
          

          all widget set dark, but the picture is not set in the main window background.
          :(

          H.Ghassami

          raven-worxR 1 Reply Last reply
          0
          • MhM93M MhM93

            really thanks @raven-worx for reply. I change the css to this:

            QWidget , QDialog
            {
            	background:rgb(67,67,67);
            }
            
            #MainWindow
            {
            	background: url(:/myImg/1.jpg);
            }
            

            all widget set dark, but the picture is not set in the main window background.
            :(

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #13

            @MhM93
            did you read my note at the end of my last post?

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • MhM93M Offline
              MhM93M Offline
              MhM93
              wrote on last edited by
              #14

              so how can I do some thong like that? I want to set back ground image for some widget and the other widget i like to be dark. How can I do that?

              H.Ghassami

              raven-worxR 1 Reply Last reply
              0
              • MhM93M MhM93

                so how can I do some thong like that? I want to set back ground image for some widget and the other widget i like to be dark. How can I do that?

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #15

                @MhM93
                as i already said. Don't apply the background-image to the main-window but to the widget you set as central widget...

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • MhM93M Offline
                  MhM93M Offline
                  MhM93
                  wrote on last edited by
                  #16

                  Do you mean I set the main window central widget for set back ground image?could you give me example?
                  So sorry I am beginner in qt(also in English) so sorry :">

                  H.Ghassami

                  raven-worxR 1 Reply Last reply
                  0
                  • MhM93M MhM93

                    Do you mean I set the main window central widget for set back ground image?could you give me example?
                    So sorry I am beginner in qt(also in English) so sorry :">

                    raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by
                    #17

                    @MhM93
                    CSS:

                    QWidget , QDialog
                    {
                    	background:rgb(67,67,67);
                    }
                    
                    #MyCentralWidget
                    {
                    	background: url(:/myImg/1.jpg);
                    }
                    

                    CPP:

                    QFrame* centralWidget = new QFrame;
                    centralWidget->setObjectName("MyCentralWidget");
                    mainWindow->setCentralWidget( centralWidget );
                    

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    3
                    • MhM93M Offline
                      MhM93M Offline
                      MhM93
                      wrote on last edited by
                      #18

                      really thanks. now I get it. you mean I set the frame for central widget in the main window and set the picture for it.
                      thanksss .
                      :)

                      H.Ghassami

                      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