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. setWindowTitle as SLOT

setWindowTitle as SLOT

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 619 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.
  • Y Offline
    Y Offline
    Yeke
    wrote on last edited by
    #1

    I cannot explain myself why while this works

    connect(this, SIGNAL(mysignal()), this, SLOT(showMinimized()));
    

    this does not

    connect(this, SIGNAL(mysignal()), this, SLOT(setWindowTitle("blablahblah")));
    

    Nevertheless if I do it this way it works

    connect(this, SIGNAL(mysignal()), this, SLOT(title()));
    ...
    void MyClass::title() {
        setWindowTitle("Hola");
    }
    

    Aren't both showMinimized and setWindowTitle SLOTS of QWidget? what makes the difference?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Because you don’t pass values as parameters of the connect methods. The form you are using expect parameter types. You should also get a warning at run time.

      You should take a look at Signals and Slots chapter of Qt’s documentation for more information on the subject.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      5
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        If you can, use Qt5 Connect Syntax

        These 2 both work and are checked at compile time
        connect(this, &Myclass::mysignal, this, &Myclass::showMinimized);
        connect(this, &Myclass::mysignal, this, std::bind(&Myclass::setWindowTitle,this,QStringLiteral("blablahblah")));

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        6

        • Login

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