[Qt-interest] QColorDialog position
Paul England
pengland at cmt-asia.com
Fri Jun 18 05:15:24 CEST 2010
I've got a QColorDialog that I'm using. It is brought up from a
QLineEdit which is in a QLayout, which is inside a QDialog. The idea is
for the QColorDialog to come up in the vicinity of the parent QDialog
which it does on my machine (by default). However, on another machine,
it does not. That machine has 6 monitors, so it's quite the pain to
find it.
I have a function below to center the geometry, but it doesn't seem to
work. I'm assuming that getColor() has it's own verison of show() or
exec(). I tried doing show() explicitely and got it to appear
elsewhere, but then to actually get the color I would need to connect()
to it's slots and/or reimplement something. That would actually be
quite a bit of work at this stage, though.
Any ideas?
void center_widget( QWidget* widget, const QPoint& center )
{
QRect geo = widget->geometry();
geo.moveCenter( center );
widget->setGeometry( geo );
}
void my_class_t::get_foreground()
{
QColorDialog dialog;
center_widget( &dialog, this->geometry().center() );
QColor color = dialog.getColor( clr_fgc );
// process color
}
More information about the Qt-interest-old
mailing list