Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard "About" dialog in Qt

What's the standard way to implement an "About" application dialog in Qt? You know, the kind that pops up when you go Help > About... from the application menu. I'm using Qt Designer to layout my main window, but I don't need anything fancy. It would be nice to do it in 2 lines of code instead of creating a new class or a new form in Qt Designer...

like image 515
Matt Montag Avatar asked Apr 03 '11 08:04

Matt Montag


People also ask

What is dialog in Qt?

Qt provides a set of ready-made dialogs for file, font, color-selection and more. QColorDialog. Dialog widget for specifying colors. QFileDialog. Dialog that allow users to select files or directories.

What is Qtwidgets?

Widgets are the primary elements for creating user interfaces in Qt. Widgets can display data and status information, receive user input, and provide a container for other widgets that should be grouped together. A widget that is not embedded in a parent widget is called a window.


2 Answers

You can use QMessageBox::about for simple about dialogs, or write your own QDialog subclass if you need anything more special/fancy.

like image 183
Frank Osterfeld Avatar answered Oct 09 '22 07:10

Frank Osterfeld


  1. Create a form. Right click on Project, Add New.., then select Qt in Files and Classes, select Qt Designer Form Class on right side and click choose..
  2. Select Dialog without Buttons and click next.
  3. Name it, for example "About".
  4. Open About.ui in designer and change this window as desired, i.e. add icon, text, buttons (maybe only OK button) and save it.
  5. In mainwindow.h add this object, i.e. About *about;
  6. In mainwinodw.cpp instantiate it, about = new About(this); If you put 0 instead of this, it will not be a "modal" window, so add this in parentheses.
  7. Go to Designer and in Action Editor right click on menu item and select Go to slot -> triggered.
  8. Write about->show(); in that slot.
like image 31
Mubin Icyer Avatar answered Oct 09 '22 09:10

Mubin Icyer