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

Custom widget stylesheet

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.4k 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.
  • A Offline
    A Offline
    Alatriste
    wrote on last edited by
    #1

    I have my own QWidget based class

    class LFVResizeBar : public QWidget
    {
        Q_OBJECT
    
    public:
        LFVResizeBar(QWidget *parent = 0);
        ~LFVResizeBar();
    
    protected:
    
      void resizeEvent(QResizeEvent *event);
      void paintEvent(QPaintEvent *event);
    
    private:
        Ui::LFVResizeBar ui;
    };
    
    

    and in constructor I'm setting

    setStyleSheet("QWidget#LFWindowTitlteBar{background: black;}"); // object name is LFWindowTitlteBar
    

    but without effect :( what's the problem?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Are you sure you set the object name? What does qDebug() << objectName(); print when called from LFWindowTitlteBar? Where is the setObjectName("LFWindowTitlteBar"); call?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alatriste
        wrote on last edited by Alatriste
        #3

        @Alatriste said:

        // object name is
        I told you in my code..

        object name is LFWindowTitlteBar

        setStyleSheet("QWidget#LFWindowTitlteBar{background: black;}"); // object name is LFWindowTitlteBar
        
        kshegunovK 1 Reply Last reply
        0
        • A Alatriste

          @Alatriste said:

          // object name is
          I told you in my code..

          object name is LFWindowTitlteBar

          setStyleSheet("QWidget#LFWindowTitlteBar{background: black;}"); // object name is LFWindowTitlteBar
          
          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Alatriste
          Hello,
          But where do you set the object name? Could you provide the class' constructor and this implementation LFVResizeBar::paintEvent(QPaintEvent *event) as well?

          Kind regards.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • salimoneusS Offline
            salimoneusS Offline
            salimoneus
            wrote on last edited by salimoneus
            #5

            If LFVResizeBar is the widget class you want to target, I would suggest changing your CSS to QWidget#LFVResizeBar, and in the constructor of the LFVResizeBar or somewhere you need to set the name of the object to "LFVResizeBar" so the CSS will match it as Wieland indicated.

            It may work if the name doesn't match the class, but just for consistency and maintainability sake I would have them be the same.

            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