Please nominate your Qt Champions for 2021!

[SOLVED] QWidget::setWindowModified: The window title does not contain a '[*]' placeholder

  • Hi everyone!

    I'm new to Qt and I started learning it from instruction videos in eLearning section. When I got to events I found something strange - the placeholder. I copied the code from this video (I home without mistakes) and compiled it. There was no errors and program executes correctly, but the compiler says "QWidget::setWindowModified: The window title does not contain a '[*]' placeholder". And I don't understand what is wrong. What is exactly a placeholder and where is it used?

    The mistake is here:
    @MainWindow::MainWindow(QWidget *parent) : QWidget(parent)
    QLabel *label = new QLabel(tr("Try to close the window."));
    QVBoxLayout *vertical = new QVBoxLayout(this);
    vertical->addWidget(label, 0, Qt::AlignCenter);

    this->setWindowTitle(tr("Close Event[*]"));
    Can anybody help me?

  • You must call

    setWindowTitle(tr("My crazy MainWindow[*]"));

    Important: The window title must contain a "[*]" placeholder. See the API docs on "QWidget property windowModified": for further details.

    This is not an error, but a warning. It is not generated during compilation but during run-time, as the C++ compiler cannot know the value of the windowTitle property. This is only set at runtime.

  • Firstly, thanks for response.

    I know that it's just a warning. But what makes me sad is the fact that I did everything correctly. And I call this function in line 8 of onclosed code and it even has this '[*]' thing. So there shouldn't be any warning. Of course I can live with that, but when someone executes it from a console, this warning is visible and tells that something is not ok. I would like to eliminate it somehow.

    If I am wrong somewhere, please correct me :)

  • You must set the window title before you call setWindowModified() - just swap the two lines :-)

  • Oh... oh... Thanks a lot! I wasted 2h on that :P I was thinking about it, but in that video it was shown just as in the first post.

  • Do you have a link to that video and maybe some timestamp (minute/second) where that appears?

  • "Here is the video":
    The mentioned part of code is shown around 5:55 at the top of the screen.

  • Indeed. Maybe you should leave some feedback (there is a link in the text below the video player). At least they can add some hint on that page, so that other users do not get bitten by this too.

  • [quote author="eclipse" date="1291413438"]"Here is the video":
    The mentioned part of code is shown around 5:55 at the top of the screen.[/quote]

    Thanks for the video link

Log in to reply