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
Forum Updated to NodeBB v4.3 + New Features

Add css on widget inside an other one

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 486 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.
  • M Offline
    M Offline
    marius.thorre
    wrote on 10 Jan 2024, 13:35 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

    J 1 Reply Last reply 10 Jan 2024, 13:37
    0
    • M marius.thorre
      10 Jan 2024, 13:35

      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

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 10 Jan 2024, 13:37 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 10 Jan 2024, 13:49 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

        J 1 Reply Last reply 10 Jan 2024, 13:56
        0
        • M marius.thorre
          10 Jan 2024, 13:49

          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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 10 Jan 2024, 13:56 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 10 Jan 2024, 14:02 last edited by
            #5

            parent is QWidget. I had it on cpp file

            J 1 Reply Last reply 10 Jan 2024, 15:28
            0
            • M Offline
              M Offline
              marius.thorre
              wrote on 10 Jan 2024, 14:14 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
                10 Jan 2024, 14:02

                parent is QWidget. I had it on cpp file

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 10 Jan 2024, 15:28 last edited by jsulm 1 Oct 2024, 15:28
                #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 10 Jan 2024, 15:37
                1
                • J jsulm
                  10 Jan 2024, 15:28

                  @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 10 Jan 2024, 15:37 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

                  P 1 Reply Last reply 10 Jan 2024, 16:57
                  0
                  • M marius.thorre
                    10 Jan 2024, 15:37

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

                    P Offline
                    P Offline
                    Pl45m4
                    wrote on 10 Jan 2024, 16:57 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 11 Jan 2024, 07:20

                    6/9

                    10 Jan 2024, 14:14

                    • Login

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