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. Add css on widget inside an other one

Add css on widget inside an other one

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 475 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.
  • M Offline
    M Offline
    marius.thorre
    wrote on last edited by
    #1

    Hi

    I ve a Widget A which contains 4 QPushButtons and i add this widget on a other one B. When i had some css on A for buttons, css desepear on B. I don't know why

    Thanks

    Marius

    jsulmJ 1 Reply Last reply
    0
    • M marius.thorre

      Hi

      I ve a Widget A which contains 4 QPushButtons and i add this widget on a other one B. When i had some css on A for buttons, css desepear on B. I don't know why

      Thanks

      Marius

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @marius-thorre said in Add css on widget inside an other one:

      When i had some css on A for buttons

      Please show how you do this

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        marius.thorre
        wrote on last edited by
        #3

        ok that s it

        #include "imagedit.h"
        #include "ui_imagedit.h"

        ImagEdit::ImagEdit(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::ImagEdit)
        {
        ui->setupUi(this);

        //Instance
        
        editionarea = new EditionArea();
        libraryarea = new LibraryArea();
        settingarea = new SettingArea();
        toolboxarea = new ToolboxArea();
        
        settingarea->setStyleSheet("background-color: red");
        

        }

        ImagEdit::~ImagEdit()
        {
        delete ui;
        }

        and one of them:
        #include "settingarea.h"
        #include "ui_settingarea.h"

        SettingArea::SettingArea(QWidget *parent)
        : QWidget(parent)
        , ui(new Ui::SettingArea)
        {
        ui->setupUi(this);
        }

        SettingArea::~SettingArea()
        {
        delete ui;
        }

        36419f0b-889a-4f73-bde0-fa62733b959b-image.png

        c652c0ad-bcaa-4275-a823-11a5341b83df-image.png

        a69bee9d-5b23-4de3-8228-a1356eefb94b-image.png

        i see buttons but whithout color

        jsulmJ 1 Reply Last reply
        0
        • M marius.thorre

          ok that s it

          #include "imagedit.h"
          #include "ui_imagedit.h"

          ImagEdit::ImagEdit(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::ImagEdit)
          {
          ui->setupUi(this);

          //Instance
          
          editionarea = new EditionArea();
          libraryarea = new LibraryArea();
          settingarea = new SettingArea();
          toolboxarea = new ToolboxArea();
          
          settingarea->setStyleSheet("background-color: red");
          

          }

          ImagEdit::~ImagEdit()
          {
          delete ui;
          }

          and one of them:
          #include "settingarea.h"
          #include "ui_settingarea.h"

          SettingArea::SettingArea(QWidget *parent)
          : QWidget(parent)
          , ui(new Ui::SettingArea)
          {
          ui->setupUi(this);
          }

          SettingArea::~SettingArea()
          {
          delete ui;
          }

          36419f0b-889a-4f73-bde0-fa62733b959b-image.png

          c652c0ad-bcaa-4275-a823-11a5341b83df-image.png

          a69bee9d-5b23-4de3-8228-a1356eefb94b-image.png

          i see buttons but whithout color

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @marius-thorre said in Add css on widget inside an other one:

          settingarea->setStyleSheet("background-color: red");

          What is settingarea and why it does not have a parent? Without setting "this" as parent it is not part of ImagEdit.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            marius.thorre
            wrote on last edited by
            #5

            parent is QWidget. I had it on cpp file

            jsulmJ 1 Reply Last reply
            0
            • M Offline
              M Offline
              marius.thorre
              wrote on last edited by
              #6

              @jsulm

              settingArea is a form that i ve created and i want to add it in an other form with css setting too

              1 Reply Last reply
              0
              • M marius.thorre

                parent is QWidget. I had it on cpp file

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by jsulm
                #7

                @marius-thorre said in Add css on widget inside an other one:

                parent is QWidget. I had it on cpp file

                Where? In the code you posted you do not set parent:

                settingarea = new SettingArea("WHERE IS THE PARENT?");
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                M 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @marius-thorre said in Add css on widget inside an other one:

                  parent is QWidget. I had it on cpp file

                  Where? In the code you posted you do not set parent:

                  settingarea = new SettingArea("WHERE IS THE PARENT?");
                  
                  M Offline
                  M Offline
                  marius.thorre
                  wrote on last edited by
                  #8

                  @jsulm it was that ... sorry i m beginner in C++ et Qt and sometime do some mistakes, thanks a lot for your help

                  Pl45m4P 1 Reply Last reply
                  0
                  • M marius.thorre

                    @jsulm it was that ... sorry i m beginner in C++ et Qt and sometime do some mistakes, thanks a lot for your help

                    Pl45m4P Offline
                    Pl45m4P Offline
                    Pl45m4
                    wrote on last edited by
                    #9

                    @marius-thorre

                    Please mark the topic as "solved" if you dont have further questions and your issue got resolved.


                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                    ~E. W. Dijkstra

                    1 Reply Last reply
                    0
                    • M marius.thorre has marked this topic as solved on

                    • Login

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