A few questions on Qt
Hey everyone, I had a few questions I was wondering if anyone could answer :D Thanks for your help guys!
1) How can you open a text document with Notepad? (I don’t mean with QFile or QTextStream)
2) How can you open a new window from pressing a button on your QMainWindow? (I want to open a About the program window by pressing a button on my QMainWindow)
3) How do you make QFileDialog only work with files?
Ad. 1. Certainly no cross-platform way of doing that. I don’t use Windows, but I guess it would involve running something like “notepad fileToOpen.txt” in the terminal (console). In Qt, you can do that with QProcess.
Ad. 2. Connect button’s clicked() signal to a slot of your choice. In the slot, run:
- QMessageBox::aboutQt(parent, title);
This can also be done in many other ways.
Ad. 3. What do you mean by “work with files”? You mean you want to display only files? That would be strange. Anyway, what you probably need is to look into static members of QFileDialog (::getOpenFileName(), ::getOpenFileNames() etc.), or/ and the QFileDialog::FileMode flag.