Results 1 to 5 of 5

Thread: QlistWidget and StackedWidget

  1. #1
    Join Date
    Sep 2012
    Posts
    44
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QlistWidget and StackedWidget

    Hi,

    i have QListWidget and QStackedWidget.
    I want when select some item from the list to change the widget loaded in Stacked Widget.
    Probably i should use currentIndex() signal in order to trigger the change.

    Any ideas?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QlistWidget and StackedWidget

    QListWidget has signals that give you both the new selected QListWidgetItem and the new selected text so you can use one of those (depending on your needs).

  3. #3
    Join Date
    Sep 2012
    Posts
    44
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QlistWidget and StackedWidget

    Thank you.
    Is there any error in this, because it still doesn't work:
    Qt Code:
    1. connect(ui->listWidget_settings, SIGNAL(currentTextChanged ( const QString & currentText )),this, SLOT(changeWidget()));
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QlistWidget and StackedWidget

    The connect statement is incorrect: you don't put signal/slot parameter name in the connect statement (so just const QString& remove currentText) and a second stuff is that most likely you would like the changeWidget() to take that string that changed in the QLisWidget and create/modify the widget accordingly with that QString: so you can create void changeWidget(const QString& changedText) (if you didn't put it now, don't forget to add public slots: access specifier) and use the text (changed from the QListWidget) into definition to create/update the widget so the connect will become:
    Qt Code:
    1. connect(ui->listWidget_settings, SIGNAL(currentTextChanged ( const QString& )),this, SLOT(changeWidget(const QString&))); //at connect you write just the type of parameters
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Sep 2012
    Posts
    44
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QlistWidget and StackedWidget

    Thank you!
    Problem solved

Similar Threads

  1. Updating a view from StackedWidget
    By thefatladysingsopera in forum Newbie
    Replies: 1
    Last Post: 28th October 2011, 18:03
  2. stackedWidget with arrows
    By Zergi in forum Newbie
    Replies: 2
    Last Post: 16th July 2008, 10:20
  3. A Question about stackedwidget
    By anafor2004 in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 14:57
  4. stackedWidget
    By dragon in forum Newbie
    Replies: 3
    Last Post: 18th October 2007, 16:05
  5. StackedWidget overlapped
    By manucorrales in forum Qt Programming
    Replies: 5
    Last Post: 14th July 2006, 20:18

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.