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. Resizing widgets in QTabWidget leaves blank space if border disabled
Forum Updated to NodeBB v4.3 + New Features

Resizing widgets in QTabWidget leaves blank space if border disabled

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 127 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.
  • 0 Offline
    0 Offline
    04CH
    wrote on last edited by 04CH
    #1

    I have QTabWidget with widgets that have fixed size depending on font size in it.

    I want to disable border of QTabWidget, so i use this line of code:

    setStyleSheet("QTabWidget::pane { border: 0; }");
    

    But now, when i resize widgets i have an empty gaps on bottom and right side (~3 - 5px).
    If not use this line of code, then after resizing on each side of widget these gaps are equal.

    This is resizing code (SessionsWidget inherits QTabWidget):

    void SessionsWidget::updateSize(int size)
    {
        static_cast<Placeholder*>(widget(0))->setFontSize(size);
        for (auto i = 1; i < count(); ++i)
            static_cast<Terminal*>(widget(i))->setFontSize(size);
    }
    
    void Terminal::setFontSize(int size)
    {
        m_Impl->m_Display->setFontSize(size);
    }
    
    void Display::setFontSize(int size)
    {
        auto currentFont = font();
        currentFont.setPointSize(size);
        setFont(currentFont);
        updateSize();
    }
    
    void Display::updateSize()
    {
        QFontMetrics metrics(font());
    
        m_FontHeight = metrics.height();
        m_FontWidth = metrics.horizontalAdvance("A");
    
        setFixedSize(m_FontWidth * 80, m_FontHeight * 25);
    
        update();
    }
    

    How to fix this? Thanks

    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