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. QDialog / QTabwidget bug

QDialog / QTabwidget bug

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 495 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.
  • MegamouseM Offline
    MegamouseM Offline
    Megamouse
    wrote on last edited by Megamouse
    #1

    We have a QDialog thats completely designed with layouts.
    The main QVBoxLayout contains a QTabWidget that consists of several Widgets which are handled through layouts as well.

    The Problem now is that whenever we execute the dialog with a tab other than the first one, it is a bit smaller than that and resizes as soon as we change the tab to the first one.

    The weird thing is that it doesn't show this behaviour when I switch the tabs around, so that my original first tab is somewhere else in the order. Because now every tab opens in same size and changing tabs doesn't resize anymore.

    Does anyone know why this could happen?
    I suspect a bug in the way QTabWidgets calculate their size in regard to the content of the first widget, meaning it may ignore the first widget's layout at some point in the progress of exec() or show() or wherever it might be.

    Edit: I tried with several sizeconstraints and even with setfixedsize and I always get the same result.
    It wouldn't be a problem if I didn't need the tab to be first, but with those shenanigans I have to hack a solution.
    For example showing the first tab and quickly switching to the others would works. But thats ugly.
    I thought I fixed the problem once by iterating through all tabs with setCurrentIndex, but for some reason it doesn't work anymore.

    1 Reply Last reply
    0
    • MegamouseM Offline
      MegamouseM Offline
      Megamouse
      wrote on last edited by
      #2

      I fixed it with a simpler hack:

      int MyDialog::exec()
      {
      	QTimer::singleShot(0, [=]{ ui->tabWidget->setCurrentIndex(tab_index); });
      	return QDialog::exec();
      }
      

      tab_index member was set beforehand.
      this works because basically my first tab is adjusted to size now but then we immediately switch to the other.

      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