Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Custom sighnal in main window not recognized?
Forum Update on Monday, May 27th 2025

Custom sighnal in main window not recognized?

Scheduled Pinned Locked Moved Solved General and Desktop
colordialogcustom signalsignal & slot
3 Posts 2 Posters 448 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BDC_Patrick
    wrote on 27 Aug 2020, 10:06 last edited by BDC_Patrick
    #1

    Hi there.. again..

    Situation:
    I have a MainWindow called tgs_mainwindow, and a Dialog called dialog_programsettings.

    Inside the Settings, the user should be able to select a color as editor background.
    The Editor background color is changed in the mainwindow, via stylesheet.
    Like this:

    qss = QString("#Area_DisplayContents {background: #" + EditorColor + "}");
        ui->Area_DisplayContents->setStyleSheet(qss);
    

    Where EditorColor is a QString with "FFFFFF" Format (without #)

    The header of the dialog:

    class Dialog_ProgramSettings : public QDialog
    {
        Q_OBJECT
    
    public:
        explicit Dialog_ProgramSettings(QWidget *parent = nullptr);
        ~Dialog_ProgramSettings();
    
    signals:
        void recolorEditorUI();
    
    private:
        Ui::Dialog_ProgramSettings *ui;
    
    private slots:
        void ShowColorDialog();
        void recolorPreview(QColor col);
    };
    

    Has a custom signal inside it. It gets emitted via a function in cpp. The Function is called, cause a testimage gets recolored with this function, too.

    In the mainwindow cpp, i open the Dialog with this code:

                Dialog_ProgramSettings *dialog = new Dialog_ProgramSettings(this);
                dialog->setWindowTitle(tr("Einstellungen"));
                dialog->exec();
                connect(dialog, SIGNAL(recolorEditorUI()), this, SLOT(RecolorEditor()));
    

    RecolorEditor is the Function, that recolors the Background.
    This connection seems never to be triggered, cause the Background color never changes..

    What do i have to do, to make it work?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 27 Aug 2020, 10:12 last edited by
      #2

      Call connect() before you call exec() :-)

      Plus, two general remarks:

      • if only possible, use the new connect syntax
      • check return value of connect() to make sure the connection has actually been established

      (Z(:^

      B 1 Reply Last reply 27 Aug 2020, 10:18
      4
      • S sierdzio
        27 Aug 2020, 10:12

        Call connect() before you call exec() :-)

        Plus, two general remarks:

        • if only possible, use the new connect syntax
        • check return value of connect() to make sure the connection has actually been established
        B Offline
        B Offline
        BDC_Patrick
        wrote on 27 Aug 2020, 10:18 last edited by
        #3

        @sierdzio Thank you very much :D

        1 Reply Last reply
        1

        1/3

        27 Aug 2020, 10:06

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved