[Solved] Qt Main Window resize problem (Linux/Ubuntu 11.04, Gnome)
-
wrote on 4 Jun 2011, 01:50 last edited by
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)! -
wrote on 4 Jun 2011, 08:05 last edited by
Hard to tell. Here are just some thoughts.
Can you post screenshots?
How does it behave in Qt Creator when you use form preview?
Do you have graphics problems on your ubuntu?
Do you use layouts?
I hope this helps to find the right direction.
-
wrote on 4 Jun 2011, 08:42 last edited by
Do you use layouts?
-
wrote on 4 Jun 2011, 13:08 last edited by
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
-
wrote on 4 Jun 2011, 13:40 last edited by
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? -
wrote on 4 Jun 2011, 14:14 last edited by
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);
@ -
wrote on 4 Jun 2011, 15:01 last edited by
Off topic: It seems you want to copy the style from QtCreator :D
-
wrote on 4 Jun 2011, 15:08 last edited by
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).
-
wrote on 4 Jun 2011, 22:39 last edited by
I figured it out. The painter cant be a pointer (I should have known that). The icon isn't showing at the moment with the updated code, but I'm sure I can figure that out. Thanks again to everybody.
EDIT: It worked. Just had to rebuild everything.
9/9