![](/img/trans.png)
[英]How to make the tabs of QTabWidget fit the size of the container - Adjust its lenght?
[英]QProgressDialog: How to adjust the size of the dialog to fit its contents?
我用下面的代碼測試:
QProgressDialog* dialog = new QProgressDialog("Message", "Close", 0, 10);
dialog->setWindowTitle("Long Long Long Long Title");
dialog->setCancelButtonText("Long Long Long Click this button to cancel");
dialog->setWindowModality(Qt::ApplicationModal);
dialog->adjustSize();
dialog->setValue(5);
標題和取消按鈕文字被剪切。 我調用了AdjustSize(),但是它沒有用。 如何調整對話框的大小以適合其內容?
您可以使用以下內容:使用QLayout ...
QProgressDialog* dialog = new QProgressDialog("Message", "Close", 0, 10);
dialog->setWindowTitle("Long Long Long Long Title");
dialog->setCancelButtonText("Long Long Long Click this button to cancel");
dialog->setWindowModality(Qt::ApplicationModal);
dialog->setValue(5);
QVBoxLayout *layout = new QVBoxLayout;
foreach (QObject *obj, dialog->children()) {
QWidget *widget = qobject_cast<QWidget *>(obj);
if (widget)
layout->addWidget(widget);
}
dialog->setLayout(layout);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.