Hi,
I am sub classing QMainWindow and there is a resizeEvent.
I am also creating some QDockWidgets inside.
How do I setup resizeEvent for dock so that it calls this->resizeEvent.
Cheers
Prashant
Printable View
Hi,
I am sub classing QMainWindow and there is a resizeEvent.
I am also creating some QDockWidgets inside.
How do I setup resizeEvent for dock so that it calls this->resizeEvent.
Cheers
Prashant
Why do you want to do that? resizeEvent will be called for your widget when it gets resized.
The central widget is a tabWidget, where each tab contains a textedit. When I resize the docks at left, right or bottom, textedit doesn't resize as expected.
When resizing the window(maximize, minimize, stretch) , things are working fine, as I am
adjusting the size of textedit:
Code:
this->tabWidget->centerText->resize( this->tabWidget->currentWidget()->size());
May be I am doing wrong and there is another way of doing this correctly.
Prashant
Calling a resizeEvent will not make anything resize. It is an event that informs a widget it has (already) been resized. Your problem seems to be that you didn't apply a layout to some of the widgets in the tab widget.
Ok,
Here are some details:
1. I am sub classing tabWidget.
2. There is only one textEdit widget.
3. When ever you create a new tab, you reparent the textEdit to the newly created tab.
4. when you delete a tab, you reparent the textEdit to the current tab.
Code:
void myTabWidget::addNewTab(const char *tabName) { // Create a new widget // Add a new tab // Set size of this widget to size of this newTab->resize(this->size()); // Make this tab current one. this->setCurrentIndex(this->count()-1); // Parent text to this tab. centerText->setParent(newTab); // Set size of text equal to size of tab centerText->resize(newTab->size()); }
Code:
void myTabWidget::tabChanged(int index) { // Reparent text to current widget centerText->setParent(this->currentWidget()); //Note: //The widget becomes invisible as part of changing its //parent, even if it was previously visible. You must //call show() to make the widget visible again. centerText->show(); // Set size of text equal to size of tab/widget centerText->resize(this->currentWidget()->size()); }
This tab widget is centerWidget and there are docks (left, right and bottom) to it.
When you resize the main window or you resize the dock the textedit should cover the
whole tab area.
Prashant
As I said, you're not applying layouts to the tabs. Furthermore it looks like you're trying to reuse the same widget for multiple tabs which doesn't make much sense... Anyway:
Code:
void ...::addNewTab(...){ addTab(newTab, ...); centerTab->setParent(newTab); l->addWidget(centerTab); // * }
If you want to have the text edit with the same contents in each tab I would advise to do this instead:
Code:
void ...::addNewTab(...){ addTab(newTab, ...); te->setDocument(centerTab->document()); // * l->addWidget(te); }
Thanks for the tip. It worked.
Cheers
prashant