I created a popup window like this:
QFileInfo FileA = "AAA";
QFileInfo FileB = "BBB";
if (fileA.exists() == false & (fileB.exists() == false))
{
QFrame* PopupWin = new QFrame(this, Qt::Popup | Qt::Window );
PopupWin->setGeometry(450,450, 400, 200);
PopupWin->setLineWidth ( 3 );
PopupWin->setMidLineWidth ( 1 );
PopupWin->setFrameStyle ( QFrame::Box | QFrame::Raised);
QLabel *message = new QLabel(PopupWin);
message->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
message->setGeometry(100,50, 200, 100);
message->setText("blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"bluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu"
"bliiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"
"bleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
"bloooooooooooooooooooooooooooooooooooooooooooooo");
PopupProzess->show();
}
I have three questions:
- When the window pops up I can’t see the whole text, just a part of
the first line of the label. How can I show the whole text? - The frame is closed when clicking
anywhere at the screen. How do disable this “anywhere-click-close”
and create a pushbutton or a kind of cross that closes the
frame/window? - How do I fit the text right into the label and the label right
into the frame?
I searched in the Qt Doc and also googled, but did not find the solutions. greetings
Why are you creating a
QFrame? What you want is aQDialog.QtDesignerin order to design your dialogQDialogcorresponding to the dialog you designedexecin order to show it modally.This way your code will be cleaner and much easier to read.
Also there is no reason to hardcode the geometry of a UI element. This is what
QtDesigneris for.Concerning the label, as spbots already answered you have to set the
wordWrapproperty.