Results 1 to 6 of 6

Thread: QTabBar and connect..also QTabWidget

  1. #1
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QTabBar and connect..also QTabWidget

    Hi
    I am trying to use a connect statement in a QWidget class on a tabBar declared in this class,i have included other class to this class and in slot i want a member of that class to be called ,so below in the code are two connect statements and both dont work

    Qt Code:
    1. #include "NineSilicaWidget.h"
    2. class NetworkInterface : public QWidget
    3. {
    4. ..
    5. QTabBar *tabBar;
    6. NineSilicaWidget *nineSilica;
    7. ..
    8. ..
    9. connect(tabBar,SIGNAL(currentChanged(int)),this,SLOT(setEnabled(bool)));
    10.  
    11. connect(tabBar,SIGNAL(currentChanged(int)),nineSilica,SLOT(someSlot()));
    12. ..
    13. }
    To copy to clipboard, switch view to plain text mode 
    Also,if any one can clarify me the difference between QTabBar and QTabWidget...i dont get the idea clearly from the docs

  2. #2
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTabBar and connect..also QTabWidget

    I tried to follow the 4 points of how to create a tab in QTabWidget:
    The normal way to use QTabWidget is to do the following:

    1. Create a QTabWidget.
    2. Create a QWidget for each of the pages in the tab dialog, but do not specify parent widgets for them.
    3. Insert child widgets into the page widget, using layouts to position them as normal.
    4. Call addTab() or insertTab() to put the page widgets into the tab widget, giving each tab a suitable label with an optional keyboard shortcut.
    Qt Code:
    1. #include "NineSilicaWidget.h"
    2.  
    3. class NetworkInterface : public QWidget
    4. {
    5. Q_OBJECT
    6.  
    7. public:
    8. NetworkInterface(QWidget *parent = 0);
    9. ~NetworkInterface();
    10.  
    11. private:
    12.  
    13.  
    14. QTabWidget *tabWidget;
    15. }
    16.  
    17. NetworkInterface::NetworkInterface(QWidget *parent)
    18. : QWidget(parent)
    19. {
    20. ui.setupUi(this);
    21.  
    22. setFixedSize(700,500 );
    23.  
    24. tabWidget = new QTabWidget(this);
    25.  
    26. tabWidget->addTab(new NineSilicaWidget(),"NineSilicaWidget");
    27. }
    28.  
    29. NineSilicaWidget::NineSilicaWidget(QWidget *parent)
    30. : QWidget(parent)
    31. {
    32. //ui.setupUi(this);
    33. ..
    34. runButton = new QPushButton("Run");
    35. ..
    36. }
    To copy to clipboard, switch view to plain text mode 

    But in the output only the tab is shown and noo push button..

  3. #3
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTabBar and connect..also QTabWidget

    Any one ??

  4. #4
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QTabBar and connect..also QTabWidget

    I haven't used QTabBar and I also had trouble understanding the docs, but from playing around a little with QTabWidget and QTabBar things became clearer.

    This is my conclusion: You can't add a button with QTabWidget::addTab() only an icon and/or a string. So you need to create a QTabBar and use QTabBar::setTabButton() to add your NineSilicaWidget. Then add your new QTabBar to your QTabWidget with setTabBar().

    As I said above I've only tried this in a simple experiment so no guarantees.

    HTH If you need more detail post back.

  5. #5
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTabBar and connect..also QTabWidget

    I wont be giving time to this task for the next few days as i am busy with other things but once i will have anything to share i will come bak..Thanks for the reply..

  6. #6
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTabBar and connect..also QTabWidget

    i have started working on the same project after a month or soo..and after reading the Tab docs what i understand is that if you are using TabWidget then you can display the tabs and its widget and you dont necessarily need to use the QTabBar with QTabWidget and vice versa...Still i am stuck while i am using QTabWidget and it does not works and am confused what is best in my scenario ,a QTabWidget or QTabBar...

Similar Threads

  1. QTabBar/QTabWidget problems on S60
    By ojai0217 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th October 2009, 01:30
  2. Hiding QTabBar on QTabWidget
    By araglin in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2009, 09:08
  3. Using QTabBar as QTabWidget replacement
    By invictus in forum Qt Programming
    Replies: 0
    Last Post: 16th August 2008, 01:57
  4. Problems with CSS for QTabBar and QTabWidget
    By visor_ua in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2008, 08:38
  5. QTabBar and a QTabWidget-like frame
    By eelik in forum Newbie
    Replies: 2
    Last Post: 16th January 2008, 18:17

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.