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!
-
How can you open a text document with Notepad? (I don't mean with QFile or QTextStream)
-
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)
-
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.
-
Thanks for your reply. For the 2nd question, I meant with a already created *.ui file, not with a QMessageBox. Thanks!
-
The procedure is very similar. You have to include the UI header, initialise the object somewhere in your code (e.g. in main window's constructor. This, again, can be done in many ways). Next, connect button's signal to your slot, and there call:
@
myNewWindow->show();
@ -
I am beginner to QT and have a question, I am not sure If I am posting in correct place. Please try to help me with this,
My Question: ScrollView {
style: ScrollviewStye{}
ColumnLayout {
''''''''
}
}
Scrollview works fine(i.e. Iam able to move scrollbar with mouse) but scrollbar doesnot react to up and down arrow keys with keyboard. -
I am beginner to QT and have a question, I am not sure If I am posting in correct place. Please try to help me with this,
My Question: ScrollView {
style: ScrollviewStye{}
ColumnLayout {
''''''''
}
}
Scrollview works fine(i.e. Iam able to move scrollbar with mouse) but scrollbar doesnot react to up and down arrow keys with keyboard.