qt4.7

Qt - how to save my QTableView as a Excel File?

℡╲_俬逩灬. 提交于 2021-02-04 15:32:09
问题 Can anyone plz help me, how to save my QtableView as a Excel File. I have a QTableView and a QPushButton (Save Button). If i enter the values in my QtableView and if i click the Save Buttton the QTableView items should be saved as Excel File. Plz Help me. Thanks.. 回答1: Have a look at this thread My-approach-to-export-QTableView-data-to-a-Microsoft-Excel-file. I got this link by asking Google for: QTableView save. For the solution there you need a Qt with ODBC enabled which is not the default.

Widget background not transparent when using QGraphicsView but transparent when using QGridLayout

蓝咒 提交于 2021-01-27 12:50:50
问题 When I was using QGridLayout to display my widgets, only the widget was shown and the part of the image that was transparent was not shown. Now I switched to using QGraphicsScene and QGraphicsView, and now my images have a gray background wherever they used to be transparent. void Piece::paintEvent(QPaintEvent *) { string image = ":/images/" + color + piece + ".png"; pixmap.load(image.c_str()); //pixmap.setMask(pixmap.createMaskFromColor(QColor(240, 240, 240))); QPainter paint(this); paint

How does designer create a Line widget?

别等时光非礼了梦想. 提交于 2020-01-14 07:12:13
问题 In Qt Designer , you can drag a "Line" widget , which will create a line in your layout. But I checked the document and headers , I didn't find the "Line" header / widget , what was it ? 回答1: In Qt 5.7 the code generated by Qt Designer for a Horizontal Line (which can be checked in the menu using "Form/View Code...") is: QFrame *line; line = new QFrame(Form); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); This will create the lines you see in Qt Designer. The

How to set the PlaceHolderText for QTextEdit

假装没事ソ 提交于 2020-01-03 17:43:30
问题 I just want to set a PlaceHolderText for a QTextEdit . I know how to set it for a QLineEdit . There is a Property, setPlaceHolderText for QLineEdit. But this Property is not available for QTextEdit. Please give your valuable suggestions to solve this. 回答1: Use setTextCursor(QTextCursor&) function of QTextEdit. Use the following logic. QTextCursor textCursor; textCursor.setPosistion(0, QTextCursor::MoveAnchor); textedit->setTextCursor( textCursor ); 回答2: I was able to do this by subclassing

How to set the PlaceHolderText for QTextEdit

谁说我不能喝 提交于 2020-01-03 17:43:07
问题 I just want to set a PlaceHolderText for a QTextEdit . I know how to set it for a QLineEdit . There is a Property, setPlaceHolderText for QLineEdit. But this Property is not available for QTextEdit. Please give your valuable suggestions to solve this. 回答1: Use setTextCursor(QTextCursor&) function of QTextEdit. Use the following logic. QTextCursor textCursor; textCursor.setPosistion(0, QTextCursor::MoveAnchor); textedit->setTextCursor( textCursor ); 回答2: I was able to do this by subclassing

QNetworkRequest with ssl local certificate

孤街浪徒 提交于 2020-01-01 18:43:14
问题 I need to exchange data with server which requires local certificate (.crt file). I try this: loginRequest = QNetworkRequest(QUrl("https://somesite.com/login")); QSslConfiguration sslConf = loginRequest.sslConfiguration(); QList<QSslCertificate> certs = QSslCertificate::fromPath(Preferences::certificatePath()); qDebug() << certs.first().issuerInfo(QSslCertificate::Organization); // prints name sslConf.setLocalCertificate(certs.first()); qDebug() << "is valid " << sslConf.localCertificate()

Rebuilding again and again to view the imported QML file changes

我们两清 提交于 2019-12-23 03:30:25
问题 I have imported a qml file say A in other qml say B. Whenever I make some changes in A , it doesn't reflect in the Application. I have to again clean and rebuild to view the changes i made, which is very time-consuming. Is there an easier and efficient way of doing this, so time could be saved . Or another way of saying this is : qrc files are not added to Makefile dependencies in debug_and_release mode example A.qml Rectangle { id:xyz Button { id: ButtonA } } B.qml Rectangle{ A { id:abc } }

How do you get System default font settings in Qt?

泪湿孤枕 提交于 2019-12-18 14:15:26
问题 I am building a desktop app using Qt, my dev machine is win 7 x64 with japanese locale, standard system font is Meiryo. Most of win 7 UI is in this font, though classic/older programs such as ui font customization window itself uses different font which is MS UI Gothic. This doesn't bother me until I found that QtCreator builds my app with MS UI Gothic in one place, and Meiryo in the other. For example, qlabels, qlineedits, qcombobox all uses MS UI Gothic, but a custom completer with a

Using QWebkit to retrieve divs with a specific class

一笑奈何 提交于 2019-12-13 01:50:17
问题 I posted the question below, trying to use the QDomDocument classes. I was advised to use the QWebkit instead, but I'm very confused how to do what I need to do with QWebkit. I've never used it before so I'm rather unsure with it. Could anyone please offer any advice? Thanks! For the record, the function is using a QByteArray that when translated to text is a standard HTML file. ORIGINAL QUESTION: I have several divs in an HTML file with different classes, like this: <div class='A'>...</div>

Appending number to QString with arg() , is there better ways?

…衆ロ難τιáo~ 提交于 2019-12-12 11:03:11
问题 I've been using QString::number () to convert numbers to string for long time , now i'm wondering if there's something better than following: int i = 0; QString msg = QString ("Loading %1").arg (QString::number (i)); How can i spare QString::number () ? i checked document , seems only "%1" is applicable , no other stuff like "%d" could work 回答1: You can directly use arg() like this int i = 0; QString msg = QString ("Loading %1").arg(i); Qt will automatically convert it for you 回答2: QString's