tags:

views:

48

answers:

1

I'm trying to get every widget to scale with change in window size. I have a main window which has a QTabWidget with a QWidget holder for each tab. I then have a custom widget with a seperate .ui file that I set to fill the QWidget space of the tab. The problem is, I can't get the contents of the QWidget to expand, only the tab and QWidget of the main window. Also, I noticed if i change the ui->setupUi( ) argument for the custom widget from "this" to "parent" the problem is fixed, and the custom widget will scale correctly. The only problem with this is none of the buttons work when I do that. The application output reads out "No Slot" found errors for the buttons. What is the correct way to make this connection?

Edit: Example code

MainWindow:: ...
{
    //assign customWidget to widget placeholder on tabWidget.
    //holder is just a blank widget set in gridLayout on tab widget.
    CustomWidget * customWidget = new CustomWidget(ui->customWidgetHolder);

    setCentralWidget(ui->tabWidget); 
    //This gets the sizing I want with the tabs, but 
    //doesn't  pass it past the customWidgetHolder.
}
+1  A: 

From what I undertand, you need to use a layout, for your custom widget inside your tab

    QTabWidget* tabWidget = new QTabWidget();
    QWidget* tab = new QWidget();
    QVBoxLayout* verticalLayout = new QVBoxLayout(tab);

    YourWidget* widget = new YourWidget(tab);
    verticalLayout->addWidget(widget);

    tabWidget->addTab(tab, QString());

But you'll need to be more specific (code sample ?) about the SIGNAL/SLOT connection you've made if you want answer about it.

gregseth
QVBoxLayout *vLayout = new QVBoxLayout(ui->customWidgetHolder);customWidget = new CustomWidget(ui->deptWidgetHolder);vLayout->addWidget(customWidget); worked like a charm, thanks!
Caleb S