1 Attachment(s)
Costum dialog not longer working
I worked on a drawing software in 2012-13, but haven't touched it since. Now I'm brushing it up, and it works fine, except a costum dialog that doesn't work anymore.
Many things can have changed, but my search has so far been without result.
Here's the header and cpp-file:
penChooser.h
Code:
#ifndef PENCHOOSER_H
#define PENCHOOSER_H
#include <QColorDialog>
#include <QLabel>
#include <QPushButton>
#include <QSpinBox>
#include <QComboBox>
#include <QVBoxLayout>
#include <QGridLayout>
{
Q_OBJECT
public:
explicit penChooser
(QDialog *parent
= nullptr
);
signals:
public slots:
};
#endif // PENCHOOSER_H
penChooser.cpp
Code:
#include "penchooser.h"
penChooser
::penChooser(QDialog *parent
) :{
labWidth
= new QLabel(tr
("Pen width:"),
this);
sbWidth->setRange(1,50);
sbWidth->setValue(6);
labPen
= new QLabel(tr
("Pen type:"),
this);
sl << tr("Standard") << tr("F5 sketching") << tr("F6 User defined")
<< tr("F7 User defined") << tr("F8 User defined");
cbPen->addItems(sl);
buttonLayout->addWidget(labWidth,0,0);
buttonLayout->addWidget(labPen,0,1);
buttonLayout->addWidget(sbWidth,1,0);
buttonLayout->addWidget(cbPen,1,1);
buttonLayout->addWidget(btnExit,2,0);
buttonLayout->addWidget(btnChange,2,1);
layout->addWidget(colordialog);
layout->addLayout(buttonLayout);
setLayout(layout);
setWindowTitle(tr("Choose Pen color and width"));
cbPen->setCurrentIndex(cbPen->findText("Pen"));
sbWidth->setFocus();
}
In mainwindow.h you'll find
and in mainwindow.cpp
Code:
void MainWindow::penPick()
{
pc = new penChooser();
pc->colordialog->setCurrentColor(sketchPad->penColor());
pc->sbWidth->setValue(sketchPad->penWidth());
pc->cbPen->setCurrentIndex(0);
pc->setModal(true);
connect(pc->btnExit, SIGNAL(clicked()), this, SLOT(cancelPenPick()));
connect(pc->btnChange, SIGNAL(clicked()), this, SLOT(okPenPick()));
pc->show();
}
As said, it worked earlier and used to look like this:
Attachment 13296
Anyone out there, that can tell me what I'm missing?
Re: Costum dialog not longer working
Hi, what does "doesn't work" mean? The dialog does not look as expected? Or does it not show at all?
Ginsengelf
2 Attachment(s)
Re: Costum dialog not longer working
Quote:
Originally Posted by
Ginsengelf
Hi, what does "doesn't work" mean? The dialog does not look as expected? Or does it not show at all?
Ginsengelf
Sorry, It should look this:
Attachment 13297
...and it looks like this: (Ubuntu 18.04)
Attachment 13298
The image in my first post is from Linux (Ubuntu), while the two above is from Windows and Ubuntu..
It works as expected in Windows (I just found out), but I rarely use Windows myself, and it has a different look in Linux.
I'll upload it's current look in Linux later, when I get home from work. (Done!)
David
Re: Costum dialog not longer working
Looks like the native GTK color picker dialog does not allow embedding.
Re: Costum dialog not longer working
Can that change over time?
The image in my first post is from Ubuntu. it is taken from my sourceforge account https://sourceforge.net/projects/dastoryboard/
Re: Costum dialog not longer working
Quote:
Can that change over time?
I presume your original code was based on Qt4 if it was from 2012-3, and that you are trying to rebuild using Qt5. There were huge changes to the underlying implementation of Qt graphics between 4 and 5, even though the outward-facing UI had few changes. I agree with Christian - QColorDialog is a QDialog-based class, and generally dialogs are not designed to be embedded as child widgets in another QWidget- or QDialog-based parent. This is particularly true if the dialog is implemented as a native OS-dependent dialog and not one provided by Qt.
You might try changing the Qt::WindowFlags for the QColorDialog after you create it (but before it is shown) to remove the Qt::Dialog bit from the flags. You could also try setting the QColorDialog::ColorDialogOption to QColorDialog::DontUseNativeDialog. Don't know if either of these will work, but worth a try.
And please, if you have learned anything about encapsulation and data hiding since 2012, rewrite your code so none of the UI variable are public and you use signals and slots to communicate changes in your dialog to the rest of your program.
Re: Costum dialog not longer working
Thank you for the suggestions. I haven't got time to test it now. I'l give feedback when I've tested it.
I'm selftaught in C++ and Qt, but I've learnt a lot the last year. My plan is to get the software to work again, and then refactor it, because it is a messy bunch of spaghetti-code, with loooong functions, and not much thought on modularization and encapsulation.
Re: Costum dialog not longer working
I had time to test it on Mac this morning, and after setting the option to DontUseNativeDialog, it worked like a charm!
Thanks again!