[Solved] Qt Main Window resize problem (Linux/Ubuntu 11.04, Gnome)
-
I'm in the process of porting my Qt application from Windows to Linux and I've encountered the following problem:
Whenever I resize the window to anything greater than what it was at startup, it just shows the extra areas in grey (making it small and then normal again works though). What is visible looks the way it should (for the bigger size). I use a custom widget with the following paintEvent function:
@
void StartWidget::paintEvent(QPaintEvent *e)
{
QRect dRect = e->rect();
QPainter p(this);
QLinearGradient grad(dRect.topRight(), dRect.topLeft());
grad.setColorAt(1,Qt::white);
QColor c = Qt::lightGray;
grad.setColorAt(0, Qt::lightGray);
p.fillRect(QRect(0,0, dRect.width(), dRect.height()), grad);
p.end();
QWidget::paintEvent(e);
}
@
It worked on Windows, but not on Linux (Ubuntu 11.04). Any thoughts?EDIT: Screenshots:
Normal:
!http://img64.imageshack.us/img64/2199/hephaistosv30001.png(Normal Window)!After Resize:
!http://img863.imageshack.us/img863/5687/hephaistosv30002.png(This is what I want to fix)! -
Do you use layouts?
-
Thank you for the replies.
bq. Can you post screenshots?
Just did (see updated post)
bq. How does it behave in Qt Creator when you use form preview?
Since it's a custom widget I don't think I can use it in the form preview (or can I?)
bq. Do you have graphics problems on your ubuntu?
No.
bq. Do you use layouts?
Yes.
Thanks again
-
bq. Since it’s a custom widget I don’t think I can use it in the form preview (or can I?)
If you used Qt Creator and took a qwidget as a placeholder and then promote it to your custom widget. Then you can test the placeholder widget in the form preview.
Could you show us the ui file or code you used for the mainwidget?
What Qt Creator and Qt version are you using?
If you just use a qwidget instead of your custom widget. Do you get the same result? -
Ok I have narrowed the problem down to the buttons on the navigation bar on the left side. They have the following paintEvent function. If I comment it out, the problem goes away:
@ QStylePainter *p = new QStylePainter(this);
QStyleOptionToolButton options;
options.initFrom(this);
options.text = text();
options.icon = icon();
options.pos = pos();
options.font = font();
options.iconSize = iconSize();
options.toolButtonStyle = this->icon().isNull()?Qt::ToolButtonTextOnly:_side?Qt::ToolButtonTextBesideIcon:Qt::ToolButtonTextUnderIcon;
p->drawComplexControl(QStyle::CC_ToolButton,options);
@ -
You're right that's how I started (a year ago). It was what I knew and what I liked. The functionality has greatly expanded since then and I'm thinking about using a new user interface (it's a miniscule part of the code compared to the backend libraries).
-