nokia

How do I auto-adjust the size of a QDialog depending on the text length of one of its children?

我怕爱的太早我们不能终老 提交于 2019-11-28 03:46:55
问题 I have a QDialog I'm working with. It is made somewhat like a QMessageBox . I noticed that the size of the QMessageBox (and the size of its label) depends on the size of the message displayed. How would I make the size of my QDialog adjust automatically like a QMessageBox ? Presently my QDialog contains a button box and a label, and the QDialog is layout Vertical. (I know I could just use the message box directly but eventually I will have more complex dialogs.) 回答1: Automatic solution: Use

Qt - remove all widgets from layout?

廉价感情. 提交于 2019-11-27 03:29:45
This doesn't seem easy. Basically, I add QPushButtons through a function to a layout, and when the function executes, I want to clear the layout first (removing all QPushButtons and whatever else is in there), because more buttons just get appended to the scrollview. header QVBoxLayout* _layout; cpp void MainWindow::removeButtonsThenAddMore(const QString &item) { //remove buttons/widgets QVBoxLayout* _layout = new QVBoxLayout(this); QPushButton button = new QPushButton(item); _layout->addWidget(button); QPushButton button = new QPushButton("button"); _layout->addWidget(button); QWidget* widget

Qt - remove all widgets from layout?

为君一笑 提交于 2019-11-26 10:30:39
问题 This doesn\'t seem easy. Basically, I add QPushButton s through a function to a layout, and when the function executes, I want to clear the layout first (removing all QPushButton s and whatever else is in there), because more buttons just get appended to the scrollview . header QVBoxLayout* _layout; cpp void MainWindow::removeButtonsThenAddMore(const QString &item) { //remove buttons/widgets QVBoxLayout* _layout = new QVBoxLayout(this); QPushButton button = new QPushButton(item); _layout-