implement the resizeEvent function and do all relevant changes there, it shouldn't be difficult
implement the resizeEvent function and do all relevant changes there, it shouldn't be difficult
Hi,
Setting the minimum size of the widget don't work.
Reimplementing the sizeEvent it's not easy as you said, I think. How can I know all the widgets sizes including layout sizes?
Is there another way to do it? Or if I have to reimplement resizeEvent, how can I get all sizes?
Thanks,
Òscar Llarch i Galán
Hi,
Thanks JPN. I think that this is what I need.
Good job on this extension library.![]()
Òscar Llarch i Galán
Hi,
Not exactly waht I need. As I read from docs, "QxtLetterBoxWidget preserves the aspect ratio of its content widget". What I need is to resize the widget and also force the dialog to adjust the size to show the widgets on its new size.
Really can QxtLetterBoxWidget helps me to this job?
Thanks,
Òscar Llarch i Galán
You can make the dialog non-resizable:
and it will follow the size hint of the content. You just need to implement sizeHint() for your content widget and call updateGeometry() whenever the size hint changes.Qt Code:
To copy to clipboard, switch view to plain text mode
Well, why do you care about the dialog size when the aspect ratio of the content is correct?Really can QxtLetterBoxWidget helps me to this job?![]()
J-P Nurmi
Hi,
The widget not will resize itself. On myDialog constructor I need to change the size of myWidget:
Qt Code:
myDialog::myDialog(...) { ... int iWidth = obj->getWidth(); int iHeight = obj->getHeight(); float dAspRat = (float)iWidth/(float)iHeight; int iWidthWidget, iHeightWidget; iWidthWidget = 640; iHeightWidget = (640/dAspRat ); m_pqWidget->resize(iWidthWidget,iHeightWidget); ... //Here I want to force "this"(dialog) to fit the widgets size. }To copy to clipboard, switch view to plain text mode
Because I want to force the Widget to be 640 width and Y width(that depends on the aspect ratio).
Thanks,
Òscar Llarch i Galán
Hi,
The "sizeHint" method of myWidget is never called.Qt Code:
myLayout::myLayout(...) { ... ... } { //Here I have to calculate the size -> 640xY }To copy to clipboard, switch view to plain text mode
I don't really understand "sizeHint" behaviour, maybe because I'm not english and don't understand it's function.
See the attached image. I have this dialog and I use the QWidget(that is difficult) to see(it is on top of the other widgets). I use this QWidget as the parent of my widget(because I have not created the QtDesigner plugin).
Thanks,
Last edited by ^NyAw^; 10th February 2009 at 17:57. Reason: Atacched image forget!
Òscar Llarch i Galán
u forgot to attach the "attached image"![]()
Ok, here's an example dummy widget that changes its size hint periodically:
Now, a dummy dialog that contains the above widget and a dialog button box:Qt Code:
{ public: setStyleSheet("background: red"); // just to make it easier to see startTimer(2000); } protected: if (sh.width() > 640) updateGeometry(); // inform that the size hint has changed } private: QSize sh; };To copy to clipboard, switch view to plain text mode
This makes the whole dialog follow the size hint of the "red widget". Is this what you wanted?Qt Code:
int main(int argc, char* argv[]) { QDialog dialog; layout->addWidget(new Widget); dialog.setLayout(layout); return dialog.exec(); }To copy to clipboard, switch view to plain text mode
J-P Nurmi
Hi,
I've been trying it but I'm not able to make it works. Why the Widget have a timer that informs that its sizeHint have changed? Can't it be done on "resizeEvent", so when I call resize of the Widget it informs that the sizeHint have changed? Althought, sizeHint method is never called
It's so dificult to obtain the size of the internal widgets and the "spacing" between them and then resize the dialog to a calculated size?
Thanks,
Òscar Llarch i Galán
Bookmarks