小编J.A*_*ton的帖子

如何在 Qt 中编写自定义弹出窗口?

我的 Qt 应用程序由添加在QStackedLayout(). 现在在一些用户操作之后,我想要一个小弹出窗口来确认操作并在几秒钟后消失。我想要的是一个带有黑色边框和一些文本的灰色矩形。没有按钮,没有标题栏。

我尝试使用 QMessage Box(请参阅下面的代码)来执行此操作,但通常似乎无法调整QMessageBox(). 也不能调整大小。

QMessageBox* tempbox = new QMessageBox;
tempbox->setWindowFlags(Qt::FramelessWindowHint);  //removes titlebar
tempbox->setStandardButtons(0); //removes button
tempbox->setText("Some text");
tempbox->setFixedSize(800,300); //has no effect
tempbox->show();
QTimer::singleShot(2000, tempbox, SLOT(close()));  //closes box after 2 seconds
Run Code Online (Sandbox Code Playgroud)

那么,如何在 Qt 中编写自定义弹出窗口?

c++ qt popup

1
推荐指数
1
解决办法
4817
查看次数

标签 统计

c++ ×1

popup ×1

qt ×1