[Qt-interest] QColorDialog position
Constantin Makshin
cmakshin at gmail.com
Wed Jun 23 02:03:43 CEST 2010
QColorDialog::getColor() is a static function, so your call to center_widget() has no effect.
You should try to create color dialog with parent set to your QDialog object, i.e. do something like this:
void my_class_t::get_foreground()
{
QColor color = QColorDialog::getColor(clr_fgc, this);
// process color
}
On Friday 18 June 2010 07:15:24 Paul England wrote:
> 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
> }
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list