PDA

View Full Version : Drop downs appearing off the bottom of the page



sanjayshelke
25th May 2009, 07:06
Hi,

I have created application using QMainWIndow and added a toolbar at the bottomside of main window.

I have added drop-down menu to this toolbar.
When i clicked this drop-down menu, it is appearing off the bottom of the page( When application window is maximized ).

is there any way so that i can show drop-down upwards, when it would go off the screen.

regards,
~Sanjay

wysota
25th May 2009, 07:36
Can we see the code?

sanjayshelke
25th May 2009, 08:34
yes sure.

Here is the code fragment.


QMyToolbar ::QMyToolbar()
{
// fill color drop-down menu
m_actGroupFillColour = new QActionGroup(this);
pAction = new QAction( QIcon( QMulteMathTool::relativeToAbsolutePath ( "English_en/fillcolor.png" ) ), tr("Fill Colour"), this );
connect( pAction, SIGNAL( triggered() ), this, SLOT( setFillColor() ) );
pAction->setData( QString("Fill Colour") );
pAction->setCheckable( true );
QMenu *pMenuFillColor = new QMenu();
pMenuFillColor->setFixedSize(100,100);
QGridLayout *pGridLayout5 = new QGridLayout();
pGridLayout5->setHorizontalSpacing(5);
pGridLayout5->setVerticalSpacing(0);
pGridLayout5->setContentsMargins(4,4,4,4);
for( int nCol = 0, i = 1; nCol<4; nCol++ )
{
for( int nRow = 0; nRow<4; nRow++)
{
QString fileName = QString("English_en/brushcolor%1.png").arg(i);
fileName = QMulteMathTool::relativeToAbsolutePath(fileName);
QToolButton *pBtn = new QToolButton(this);
pBtn->setIcon( QIcon(fileName) );
pGridLayout5->addWidget( pBtn, nRow, nCol);
i++;
connect( pBtn, SIGNAL( pressed() ), this, SLOT( setFillColor() ) );
}
}
pMenuFillColor->setLayout(pGridLayout5);
pAction->setMenu( pMenuFillColor );
addAction( pAction );
m_actGroupFillColour->addAction( pAction );
m_actGroupFillColour->addAction( addSeparator() );
}


here is the snapshot of drop down menu which is created by using above code
C:\Documents and Settings\sanjays\Desktop\drop-down menu.PNG

regards,
~Sanjay

sanjayshelke
25th May 2009, 08:46
Hi,
I think snapshot may not be properly inserted.

Can you see the snapshot properly.

regards,
~Sanjay

sanjayshelke
25th May 2009, 10:17
hi Wysota,

Is there anything wrong in the code.

regards,
~Sanjay

wysota
25th May 2009, 11:13
How do you use (call) the code?

sanjayshelke
25th May 2009, 12:12
Hi,

I am calling from QMainwindow like this,

m_MyToolBar = addToolBar( tr("Property ToolBar") );
addToolBar( Qt::BottomToolBarArea, m_MyToolBar );

But i dont think it is related to problem.

regards,
Sanjay

wysota
25th May 2009, 16:47
It might be a bug in Qt.

fnmblot
26th May 2009, 20:51
You wouldn't happen to be forwarding X from an ssh session would you? I use Qt that way, and windows and drop downs always flow off the screen.