Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, October 2006
Qt 4.1.0 QFileDialog setFilters and setFilter do not work !?


Message 1 in thread

The code below produces an open file dialog that looks ok, but does not 
function properly.
The dialog correctly shows the multiple file filters in the "Files of 
type" dropdown.
However, the display does not show any files of anytype (only directories).
If I manually type in a file that I know exists in the particular 
folder, the filedialog correctly returns this files name and I can open 
the file.

If I change the code to use the static function 
QFileDialog::getOpenFileNames, then it works file.  The problem with 
this function however, is that I can use only one file filter.  I need 
to use several different file filters.

On a perhaps unrelated note, creating the QFileDialog with a constructor 
or using the static getOpenFileNames method create different dialogs!  
The latter uses the native Windows open file dialog, but the former is 
not using a native Windows dialog.  Why not use the native dialog for 
all cases?  Windows certainly supports multiple file filters in its open 
file dialogs.

Help!?

Thanks in advance,
Mark

void MainWindow::onOpen()
{
    QFileDialog fd(this, "Open molecule(s)",  ".",  "(*.pdb));
    QStringList filters;
    filters << "ArgusLab agl files (*.agl) ";
             << "PDB files (*.pdb *.ent) "
             << "MOL2 files (*.mol2)";

    fd.setFilters(filters);   
    if (fd.exec())
    {
      .......





--
 [ signature omitted ] 

Message 2 in thread

> The code below produces an open file dialog that looks ok, 
> but does not function properly.

QFileDialog was broken in several ways in the early 4.1.x
releases, see e.g. N101654, N101804, N101802, N101805.
Most (if not all) of them were fixed in 4.1.3 (+/-1).

I guess the best option would be upgrading.

Andre'

--
 [ signature omitted ] 

Message 3 in thread

Hi Qt developpers,

I'm working on a custom style design.
for qspinbox widget I don't understand how to control the up and down 
arrow states.

I use sflags for combo with success and so modify combo button 
appearance to show to user button down when he click it.
but this doesn't work for spinbox up or down buttons.
is there another way to know if button up or down is in up or down 
(clicked or not) state?

here how I do with succes for a combobox and the code that doesn't work 
for spinbox buttons.

    case CC_ComboBox:
    {
        const QComboBox *cmb = ( const QComboBox* ) widget;
   
        qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), pCg, TRUE,
               cmb->isEnabled() ? &pCg.brush( QColorGroup::Base ) :
                                  &pCg.brush( QColorGroup::Background ) );
*//** how & Style_Sunken will give the button state info (button click 
or not)*
        drawGradientButton( p, r.x() + r.width() - 2 - 16,r.y() + 2, 16, 
r.height() - 4,
                            how & Style_Sunken, TRUE );
        drawPrimitive( PE_ArrowDown, p,
            QRect( r.x() + r.width() - 2 - 16 + 2,r.y() + 2 + 2, 16 - 4, 
r.height() - 4 -4 ),
               pCg,cmb->isEnabled() ? Style_Enabled : Style_Default,opt );
        break;
    }
    case CC_SpinWidget:
    {

        //!!!! en travaux, les boutons sont pas encore bien dessines...
        const QSpinBox *spb = ( const QSpinBox* ) widget;

        //get rect for the ButtonField subcontrol for Spin Widget in 
logical coordinates.
        QRect handle = querySubControlMetrics( CC_SpinWidget, widget,
                           QStyle::SC_SpinWidgetButtonField, opt);

        //get rect for the uparrow subcontrol for Spin Widget in logical 
coordinates.
        QRect lUphandle = querySubControlMetrics( CC_SpinWidget, 
widget,QStyle::SC_SpinWidgetUp, opt);
        //get rect for the uparrow subcontrol for Spin Widget in logical 
coordinates.
        QRect lDownhandle = querySubControlMetrics( CC_SpinWidget, 
widget,QStyle::SC_SpinWidgetDown, opt);
   
        //draw area that include spinbox lineedit area and button area
        qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), pCg, TRUE,
                       spb->isEnabled() ? &pCg.brush( QColorGroup::Base ) :
                       &pCg.brush( QColorGroup::Background ) );
                          
*// !!!!! HERE how & Style_Sunken doesn't give any info about button 
state (clicked or not)*
        //draw up button area
        drawGradientButton( p, lUphandle.x(),lUphandle.y(), 
lUphandle.width(), lUphandle.height(),
                            how & Style_Sunken, TRUE );
        //draw down button area
        drawGradientButton( p, lDownhandle.x(),lDownhandle.y(), 
lDownhandle.width(), lDownhandle.height(),
                            how & Style_Sunken, TRUE );

        //to see this little arrows in gradient little frames, set color 
to button text black color
        QColor lArrowColor = qApp->palette().active().buttonText();
        QColorGroup lArrowCg(pCg);
        lArrowCg.setColor( QColorGroup::ButtonText, "black" );
       
        drawPrimitive( PE_ArrowUp, p,lUphandle,lArrowCg,spb->isEnabled() 
? Style_Enabled : Style_Default,opt );
        drawPrimitive( PE_ArrowDown, 
p,lDownhandle,lArrowCg,spb->isEnabled() ? Style_Enabled : 
Style_Default,opt );
        break;
    }

thank you for nay help.
Veronique.