August 2, 2011

alfah alfah
Lab Rat
157 posts

[Solved]tab size

 

hi

Im facing a little trouble as to how arrange the GUI elements. I have a form in which a calender is created with each date as a push button.

I need somethin like three option button at the top to go to three different menus, somethin like a tool bar with icons. Can we use the system buttons like those provided by samsung? Or using a tab widget is better.

I pulled in a default tab widget. But i cant change the size of each tab in the designer.

alfah

12 replies

August 2, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

I think this snippet [developer.qt.nokia.com] is usefull for you.

 Signature 

Qt Certified Specialist
Qt Ambassador

August 2, 2011

alfah alfah
Lab Rat
157 posts

Thanks eddy,

i have managed to use the tabs. i have put a tab widget named tabWidget with 3 tabs to an already existing form using the designer

The problem is, the calender is displayed in all the three tabs. i jus want it to be there while clicking any one of the tabs
Or do i have to create a tabwidget manually than using the designer?????????????
this is how i have created the calender buttons

  1.     for(int i=0;i<6;i++)
  2.     {
  3.         for(int j=0;j<7;j++)
  4.         {
  5.  
  6.            cellBut[i][j]=new QPushButton(this);
  7.            connect(cellBut[i][j],SIGNAL(clicked()),this,SLOT(onClickAction()));
  8.            cellBut[i][j]->setFlat(true);
  9.  
  10.         }
  11.     }

regards,
alfah

August 2, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

You can use Qt Designer to add a tabwidget, drag a QCalendar to the first, drag something else to the second and so on.
You can insert additional pages using RMB > Insert Page.

Can you show your code where you add the Calendar to the TabWidget?

 Signature 

Qt Certified Specialist
Qt Ambassador

August 2, 2011

alfah alfah
Lab Rat
157 posts

eddy,

I have already made a calender, in the sense, somthing like a custom calender.
and the tabwidget is jus the default designer one.
I cant figure out how to put the buttons/calender as whole on to the tab :(

I have used

  1.     ui->setupUi(this);
  2.  
  3.     initMemberVariable();// here buttons are created- 30/31 days
  4.  
  5.     initMonthYear();// defining each month
  6.  
  7.     initWeekDay();// arranging the week display
  8.  
  9.     createLayout();// arranging the whole layout

alfah

August 2, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

I would expect you make a class for your custom widget and then you add an instance to a specific tab widget page.
As I see your code, I guess you don’t have a class?

 Signature 

Qt Certified Specialist
Qt Ambassador

August 2, 2011

alfah alfah
Lab Rat
157 posts

  1. CalenderForm::CalenderForm(QWidget *parent): QMainWindow(parent), ui(new Ui::CalenderForm)
  2. {
  3.     ui->setupUi(this);
  4.  
  5.     initMemberVariable();
  6.  
  7.     initMonthYear();
  8.  
  9.     initWeekDay();
  10.  
  11.     createLayout();
  12.  
  13.  
  14. }

this class has few other functions defined too.
could u elaborate on ur earlier explanation, i could not follow :(

alfah

August 2, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

You are inheriting from QMainWindow. I would rather use a QWidget. Can you show your header file?

 Signature 

Qt Certified Specialist
Qt Ambassador

August 2, 2011

alfah alfah
Lab Rat
157 posts

  1. ifndef CALENDERFORM_H
  2. #define CALENDERFORM_H
  3.  
  4. #include <QtGui/QMainWindow>
  5. #include <QWidget>
  6. #include <QDate>
  7. #include <QtGui>
  8. namespace Ui
  9. {
  10.     class CalenderForm;
  11. }
  12.  
  13. class CalenderForm : public QMainWindow
  14. {
  15.     Q_OBJECT
  16.  
  17.     public:
  18.  
  19.     explicit CalenderForm(QWidget *parent = 0);
  20.     virtual ~CalenderForm();
  21.  
  22.     private:
  23.  
  24.     Ui::CalenderForm *ui;
  25.     int monthValue;
  26.  
  27.     int iArrCycleStage[6][7];
  28.     int iArrDates[6][7],ht,wd;
  29.     QString strArrayNotes[6][7];
  30.     QDate selectedDate;
  31.     QGridLayout *controlsLayout;
  32.     QLabel *monthDisplay,*yearDisplay,*weekDisplay[7];
  33.     QHBoxLayout *weekLayout;
  34.     QPushButton *cellBut[6][7],*button;
  35.     QLabel *pLabelDateDisplay,*pLabelStatus;
  36.     QString strPreviousSelection;
  37.  
  38. private slots:
  39. }

alfah

August 2, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

As I said I would subclass from QWidget.

In Qt Designer you can put a QWidget in the tab you like as a placeholder and then promote it to your CalenderForm. When compiling the QWidget will be considered as a CalenderForm and shown that way.

Here is a similar topic [developer.qt.nokia.com] on how to promote a QFrame to a custom widget. Use a QWidget instead and your CalenderForm.

 Signature 

Qt Certified Specialist
Qt Ambassador

August 2, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

have a look at this example [doc.qt.nokia.com] . it uses a QTabWidget and a class derived from QWidget to populate it.

 Signature 

Qt Certified Specialist
Qt Ambassador

August 9, 2011

alfah alfah
Lab Rat
157 posts

Hello everyone,

I have a doubt regarding the tab size. The 3 tabs that I’ve created does not entirely fill up the screen. How can i expand the tabs to fill the screen????

alfah

August 9, 2011

alfah alfah
Lab Rat
157 posts

:) i found the way too. simple, set its stylesheet :)

  1. tabWidget->setStyleSheet("QTabBar::tab{height:60px; width:160px}");

 
  ‹‹ [solved] Using the camera api on the n950      Qt SDK for Meego 1.2 - Harmattan only ? ››

You must log in to post a reply. Not a member yet? Register here!