- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
为什么 setWindowFilePath 不起作用?插槽正在工作。窗口标题不会改变。我的操作系统是 Windows 7,Qt 编译时支持 wchar_t。
test::test(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QObject::connect(ui.pushButton, SIGNAL(clicked()), SLOT(Click()));
setWindowTitle("Title");
}
void test::Click()
{
setWindowFilePath("file.txt");
}
最佳答案
也许您的问题是您在使用 setWindowFilePath()
之前已经使用了 setWindowTitle()
。来自docs :
If the window title is set at any point, then the window title takes precedence and will be shown instead of the file path string.
编辑:我刚刚尝试使用 setWindowFilePath()
并注意到它只有在您调用 之后 调用 时才会生效显示()
。由于文档中没有提到这一点,所以它闻起来像个错误...
编辑:好吧,如果不使用 setWindowTitle()
或在调用 之后调用
,我不知道你的问题是什么。我已经做了一个工作示例,所以我希望这可以帮助您找到您的问题:setWindowFilePath()
不起作用show()
#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
class MyWindow : public QMainWindow
{
Q_OBJECT
public:
MyWindow()
{
QPushButton* b = new QPushButton("Click me", this);
connect(b, SIGNAL(clicked()), this, SLOT(click()));
}
private Q_SLOTS:
void click()
{
setWindowFilePath("file.txt");
}
};
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
MyWindow w;
w.show();
return app.exec();
}
#include "main.moc"
关于c++ - setWindowFilePath 在 Qt 中根本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4624201/
我似乎无法让 setWindowFilePath 在我的任何项目中工作。该值已存储并可检索,但它从未显示在我的应用程序的标题栏中。它在我下载的示例应用程序中确实可以正常工作,但我找不到它们的不同之处。
为什么 setWindowFilePath 不起作用?插槽正在工作。窗口标题不会改变。我的操作系统是 Windows 7,Qt 编译时支持 wchar_t。 test::test(QWidget *p
我是一名优秀的程序员,十分优秀!