Qt: Richtlinien für die Benennung von GUI Elementen und Slots?



  • gibt es irgendwo Richtlinien für die Benennung von GUI Elementen und Slots in Qt? Eventuell sogar irgendwo "offizielle" Richtlinien von Nokia?

    So etwas wie:

    QGroupBox *typeGroupBox;
    QPushButton *quitButton;
    QRadioButton *windowRadioButton;
    QCheckBox *msWindowsFixedSizeDialogCheckBox;
    

    ^^ Am schluss des Namens wird immer der Widget Typ geführt

    oder

    on_checkBoxWireframe_Clicked()
    

    Slot startet mit "on_" dann kommt der Widget Typ und dann der Widget Name und am Schluss das Signal, auf das der Slot reagiert



  • Orientier dich doch an der Benennung in den examples



  • Vertexwahn schrieb:

    Slot startet mit "on_" dann kommt der Widget Typ und dann der Widget Name und am Schluss das Signal, auf das der Slot reagiert

    Du solltest bedenken, dass solche slots automatisch mit dem entsprechenden signal connected werden.



  • oh das mit dem automatischen Verbindung wusste ich bisher nicht - in dem Fall ist es natürlich Unsinn in einer Namenskonvention on_ für nicht automatisch Verbundene Slots festzulegen

    Für alle, die nicht wissen wovon wir reden:

    setupUi calls connectSlotsByName. connectSlotsByName parses the moc_ file in order to connect slots and signals. The moc_ file contains a list of all the slots for the class. The parser iterates over the list of slot names looking for the following pattern: on_objectName_signal, where on_objectName_signal is the name of the slot, objectName is the object name and signal is the signal. For example, if you have a slot named, on_doneButton_clicked(), the parser looks for an object named doneButton, a signal named clicked and then connects the on_doneButton_clicked() slot to QButton’s signal clicked().

    If you follow this naming convention, you do not need to call the connect() method, nor do you need to connect the signal via the Qt UI editor in VisualStudio. connectSlotsByName will automatically make the connection for you.


Anmelden zum Antworten