Bug 112539 - KDialogBase(KDialogBase::Swallow...) => setMainWidget(page) => Modify Page Layout => Dialog NOT Centered
Summary: KDialogBase(KDialogBase::Swallow...) => setMainWidget(page) => Modify Page La...
Status: RESOLVED WORKSFORME
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Stephan Kulow
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-13 16:40 UTC by Sebastien
Modified: 2020-12-01 04:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastien 2005-09-13 16:40:36 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    Compiled From Sources

I encounter a bug with Swallow layout for KDialogBase.
I don't have this bug with other layouts (Page, Tabbed...).

Here is a code snippet:

NewBasketDialog::NewBasketDialog(QWidget *parent)
 : KDialogBase(KDialogBase::Swallow, i18n("New Basket"), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent, /*name=*/0, /*modal=*/true, /*separator=*/true)
{
	QWidget *page = new QWidget(this);
	setMainWidget(page);
	QVBoxLayout *topLayout = new QVBoxLayout(page, /*margin=*/0, spacingHint());
	m_templates = new QIconView(page);
	topLayout->addWidget(m_templates);
	m_templates = new QIconView(page);
	topLayout->addWidget(m_templates);
	m_templates = new QIconView(page);
	topLayout->addWidget(m_templates);
	m_templates = new QIconView(page);
	topLayout->addWidget(m_templates);
}

The 4 new QIconView creations are to populate the dialog with big widgets.

Now, call dialog.exec() and the dialog is NOT CENTERED.
In fact it's somewhat centered on its parent but as if the dialog were empty...
The x and y position of the dialog seems to be computed during the setMainWidget(page) and if page change its size afterward KDialogBase doesn't care.

A workarround is to move the line "setMainWidget(page);" at the END of the constructor, and then the dialog is well centered depending on its real content.

BTW, the 3 first lines of this constructor and took from the documentation, so every programer that copy/paste those examples will encounter the bug.
Comment 1 Justin Zobel 2020-11-01 01:26:57 UTC
Sebastion can you please confirm if this is still an issue in KDE 5 series?
Comment 2 Bug Janitor Service 2020-11-16 04:33:39 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Bug Janitor Service 2020-12-01 04:33:45 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!