Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8792483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:59:05+00:00 2026-06-13T22:59:05+00:00

I have a QTabWidget with a background gradient and two problems. How dow I

  • 0

I have a QTabWidget with a background gradient and two problems.

  1. How dow I remove the anoying outline around the active tab (see image)? I tried “outline: none” like with push buttons but it does not seem to have an effect.

  2. How do I style disabled tabs? I tried :disabled and :!enabled but both do not work. // Edit: This works with :disabled but not with all properties. Seems like I tried the only not supported.

Anoying focus

The qt documentation was no help. Google either. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:59:06+00:00Added an answer on June 13, 2026 at 10:59 pm

    It seems that the focus rectangle is handled by the QStyle (not to be confused with style sheets) that is in use. You can write a QStyle subclass and apply that to your to your QTabWidget. The subclass should override the drawControl() method and do nothing if it is currently drawing the focus rectangle.

    The subclass would look something like this:

    NoFocusRectStyle.h

    #ifndef NOFOCUSRECTSTYLE_H
    #define NOFOCUSRECTSTYLE_H
    
    #include <QWindowsVistaStyle> // or the QStyle subclass of your choice
    
    class NoFocusRectStyle : public QWindowsVistaStyle
    {
    public:
        NoFocusRectStyle();
    
    protected:
        void drawControl(ControlElement element, const QStyleOption *option, 
            QPainter *painter, const QWidget *widget = 0) const;
    };
    
    #endif // NOFOCUSRECTSTYLE_H
    

    NoFocusRectStyle.cpp

    #include "NoFocusStyle.h"
    
    NoFocusRectStyle::NoFocusRectStyle()
    {
    }
    
    void NoFocusRectStyle::drawControl(ControlElement element, 
        const QStyleOption *option, QPainter *painter, 
        const QWidget *widget) const
    {
        if(element == CE_FocusFrame)
            return;
    
        QWindowsVistaStyle::drawControl(element, option, painter, widget);
    }
    

    Somewhere in your form’s intializer/constructor you would apply the custom style subclass to the tab widget:

    ui->tabWidget->setStyle(new NoFocusRectStyle());
    

    This should allow your style sheets to continue to work.

    It would be nice if there was an easier way to do this but I couldn’t find one 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have QTabWidget on my form and two tabs on it. These tabs have
I have a QLineEdit inside a widget inside a QTabWidget. Let's say that tab
I have created a tab host. Now when I set the background of each
I have a QTabWidget , where each tab has a QPlainTextEdit as its widget.
I have a QTabWidget in one of my QT windows, and it seems to
I'm using Qt and I have a QTabWidget setup in the Qt Designer Editor,
I have an inactive QMainWindow with a QTabWidget as CentralWidget which holds multiple QPlainTextEdits
Is it possible to set the TabWidget height and have the tab labels adjust?
I have 5 buttons on tab widget, 2 from left and 2 from right
I have created an tab host..what i want to do is to change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.