Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
New to this, some questions
Izzmit last edited by
I have some familiarity with c++ from college a few years agom and also C#. Since then, i have gotten a couple jobs in code maintenence. Its a great way to learn debugging/troubleshooting, but all my programming skills seems have to died.
I am currently working on a project porting a AIX Motif application to Redhat Linux -- got stuck on some drawing functions.
Motif is the most frustrating thing i have ever worked with, and this ooooold code it is used in doesnt help at all. So, I got curious and downloaded the QT sdk. I managed to put together the entire main UI together in a couple hours -- the designer works great, and it makes sense! It seems to be a great product with a strong community.
Well, I wanted to put this application together in a more modular way -- in the motif version, i have gui code so tangled with backend stuff that its impossible to seperate. Same with anything in that program. If something is removed, the entire program breaks immediately. It makes it difficult to isolate issues.
I am running into some questions that i have been unable to phrase properly in google:
QT puts everything into one single UI file, and every example seems to stick with that, putting all functionality in the mainwindow.cpp file. I want to have a separate file for "File", one for "Edit", and so on. So, each menu is self-contained.
Is this the proper approach?
Otherwise, the mainwindow.cpp will get so cluttered, with slots and stuff for each menu item and button.
Now, a programming newb question: I was trying to open a file dialog from menuFile.cpp (i wanted the functionality of the button to stay away from mainwindow). When creating the filedialog, i have to use "this"
(QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
tr("Images (*.png *.xpm *.jpg)"));
@ (from an example on qt docs.)
How do i call a filedialog from somewhere elsewhere from the mainwindow, where "this" does not exist?
And what the heck is this "(tr( " i keep seeing?!
I am assuming that i probably managed to get waaay over my head in this curiosity, but i got all excited by it and so here i am...
Thank you for any insights you can offer!
[Edit: Please wrap code in @ tags! mlong]
msx_br last edited by
You need some good book:
koahnig last edited by
welcome to devnet
Did you have a look to the "documentation ":https://qt-project.org/doc/qt-4.8/qfiledialog.html#getSaveFileName of the method?
All parameters have a default value which you may use also if set other parameters afterwards. So you may use just 0.
Izzmit last edited by
I have access to the Safari online books thing, and that one happens to be there -- Now i have one to start with.
And I did read the documentation, but I suppose i skipped right over the (0) part. I tried it, and it worked perfectly. Thank you both of you!