Search Results

Search found 2964 results on 119 pages for 'qt stylesheet'.

Page 20/119 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • Qt QNetworkAccessManager does not emit signals

    - by Emilio
    The function CheckSite() is called with an url like http://site.com, it initializes a QNetworkAccessManager object and connect() slots and signals. The manger-get() call seems work (it generates http traffic) but does not call the slot replyFinished() at the request end. What's wrong with this code? #include <QtCore> #include <QtNetwork> class ClientHandler : public QObject { Q_OBJECT QNetworkAccessManager *manager; private slots: void replyFinished(QNetworkReply *); public: void CheckSite(QString url); }; void ClientHandler::replyFinished(QNetworkReply *reply) { qDebug() << "DONE"; } void ClientHandler::CheckSite(QString url) { QUrl qrl(url); manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); manager->get(QNetworkRequest(qrl)); }

    Read the article

  • Qt - drag and drop with graphics view framework

    - by David Davidson
    I'm trying to make a simple draggable item using the graphics framework. Here's the code for what I did so far: Widget class: class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(); }; Widget::Widget(QWidget *parent) : QWidget(parent) { DragScene *scene = new DragScene(); DragView *view = new DragView(); QHBoxLayout *layout = new QHBoxLayout(); DragItem *item = new DragItem(); view->setAcceptDrops(true); scene->addItem(item); view->setScene(scene); layout->addWidget(view); this->setLayout(layout); } Widget::~Widget() { } DragView class: class DragView : public QGraphicsView { public: DragView(QWidget *parent = 0); }; DragView::DragView(QWidget *parent) : QGraphicsView(parent) { setRenderHints(QPainter::Antialiasing); } DragScene class: class DragScene : public QGraphicsScene { public: DragScene(QObject* parent = 0); protected: void dragEnterEvent(QGraphicsSceneDragDropEvent *event); void dragMoveEvent(QGraphicsSceneDragDropEvent *event); void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); void dropEvent(QGraphicsSceneDragDropEvent *event); }; DragScene::DragScene(QObject* parent) : QGraphicsScene(parent) { } void DragScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event){ } void DragScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event){ } void DragScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event){ } void DragScene::dropEvent(QGraphicsSceneDragDropEvent *event){ qDebug() << event->pos(); event->acceptProposedAction(); DragItem *item = new DragItem(); this->addItem(item); item->setPos(event->pos()); } DragItem class: class DragItem : public QGraphicsItem { public: DragItem(QGraphicsItem *parent = 0); QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); }; DragItem::DragItem(QGraphicsItem *parent) : QGraphicsItem(parent) { setFlag(QGraphicsItem::ItemIsMovable); } QRectF DragItem::boundingRect() const{ const QPointF *p0 = new QPointF(-10,-10); const QPointF *p1 = new QPointF(10,10); return QRectF(*p0,*p1); } void DragItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ if(painter == 0) painter = new QPainter(); painter->drawEllipse(QPoint(0,0),10,10); } void DragItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event){ } void DragItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event){ } void DragItem::mousePressEvent(QGraphicsSceneMouseEvent *event){ QMimeData* mime = new QMimeData(); QDrag* drag = new QDrag(event->widget()); drag->setMimeData(mime); drag->exec(); } void DragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ } main.cpp instantiates a Widget and shows it. When I try to drag the circle, the app just creates another circle over the original one, regardless of where I release the drag. qDebug() in DragScene's dropEvent() shows QPointF(0,0) everytime the drag ends. I'm having a hard time trying to understand exactly what I have to do, which classes I should subclass, which methods needs to be overriden, to make this work. The documentation on this isn't very detailed. I'd like to know how to make this work, and if there's some other, more comprehensive resource to learn about the graphics view framework, besides the official documentation (which is excellent btw, but it would be great if there was a more detailed treatise on the subject). EDIT: Following badgerr's advice, I replaced item-pos() in DragScene::dropEvent() with item-scenePos(), now the drop event creates a new circle in the drop site, which is more or less what I wanted. But the original circle is still in place, and while the drag is in progress, the item doesn't follow the mouse cursor. The QGraphicsSceneDragDropEvent documentation says that pos() should return the cursor position in relation to the view that sent the event, which, unless I got it wrong, shouldn't be (0,0) all the time. Weird. I've read in a forum post that you can use QDrag::setPixMap() to show something during the drag, and in examples I've seen pictures being set as pixmaps, but how do I make the pixmap just like the graphics item I'm supposed to be dragging?

    Read the article

  • how to set filter for directories qt qfiledialog

    - by sneha
    hello everyone,i would like to know is there any way to select only some directories and some files at a time using qfiledialog class.here i set filesfilter..but i also need to set folder filter i mean i want only certain/some folders to be selected of name (i mean i need a filter for folders too.. coz i hav a common format for my application folders like example : name.abc,flight.abc etc all these are my folder names..i want to enable selection only for these type of folders which are named at last as .abc) i am using QStringList files = QFileDialog::getOpenFileNames(this, tr("Files & Directories"), QDir::currentPath(),tr(".doc.txt") ); tr(".doc.txt") is my files filter,same way i need folders filter with name only .abc at the end

    Read the article

  • Qt Sockets and Endianness

    - by cake
    Hello I'm writing a program that uses QUdpSocket for transmiting data over the network. This is my first socket program, and I've come across an interesting problem called Endianness. My actual question in, do I have to worry about Endianness when I'm using QNetwork as my sockets library? If I do have to worry, what do I have to do to properly avoid Endianness problems? Thanks in advance.

    Read the article

  • How to get the application font color in Qt

    - by Solitaire
    Hi, I want to put some text on my UI, I am drawing the text in paint event of a widget using painter.. Here is the sample code, which shows how I am drawing the text.. QWidget::paintEvent(painter); QPainter paint(this); paint.drawText(QPoint(10,30),"Duplex"); but, the text color is looks like the default theme color, how to set the application font color to the text in paint event.. Thanks

    Read the article

  • Help Qt Widgets for creating Accessories Bar on my device

    - by Surjya Narayana Padhi
    Hi Geeks, For a handheld device I want to put a vertical Bar which will contain widgets that show the battery status of device, network connectivity status, Date and Time etc. For this Bar I have chosen a GroupBox and for the widgets inside that (lets say batter status) I am planning to use QPushButton. Is it correct I am doing or there is some special widgets for this purpose? Please suggest.

    Read the article

  • Qt undocumented method setSharable

    - by soxs060389
    I stumbled about a method which seems to be present in all DataObjects like QList, QQueue, QHash... I even investigated so far i can see the source code of it, which is inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } in qlist.h (lines 117) but what effect does it have on the QList, QQueue, QHash... ? And is it in any way related to threading? (which sounds reasonable) Thanks for any answer, and please only answer if you got actual knowledge.

    Read the article

  • qt drop event get widget

    - by eyecreate
    I'm trying to, inside a dropevent method, find out which widget was just dropped. I tried looking at the docs, but they only have commands for images and text. How do I access both the item just dropped and which widget it was dropped on?(this is drag and drop inside of a QTreeWidget)

    Read the article

  • Qt - no such signal error

    - by bullettime
    I'm trying to trigger a signal when a double click happens in one of the draggable widgets on the fridge magnets example. Here's the changes I made to the example source: DragLabel: class DragLabel : public QLabel { public: DragLabel(const QString &text, QWidget *parent); QString labelText() const; public slots: void testSlot(){qDebug()<<"testSlot";} //<-- implemented this slot protected: void mouseDoubleClickEvent(QMouseEvent *ev){emit testSignal();} //<-- overriden this method private: QString m_labelText; signals: void testSignal(); //<-- added this signal }; The only thing I changed in the implementation file is adding connect(this,SIGNAL(testSignal()),this,SLOT(testSlot())); to DragLabel's constructor. Trying to compile the project resulted in 'undefined reference to `DragLabel::testSignal()' and 'collect2: ld returned 1 exit status' errors. When I comment out the call to the signal, it compiles and runs, but gives off 'Object::connect: No such signal QLabel::testSignal() in draglabel.cpp' warning in the application output. Apparently testSignal() isn't being recognized as a signal. What am I missing?

    Read the article

  • Qt - Calling widget parent's slots

    - by bullettime
    I wrote a small program to test accessing a widget parent's slot. Basically, it has two classes: Widget: namespace Ui { class Widget; } class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(); QLabel *newlabel; QString foo; public slots: void changeLabel(); private: Ui::Widget *ui; }; Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); customWidget *cwidget = new customWidget(); newlabel = new QLabel("text"); foo = "hello world"; this->ui->formLayout->addWidget(newlabel); this->ui->formLayout->addWidget(cwidget); connect(this->ui->pushButton,SIGNAL(clicked()),cwidget,SLOT(callParentSlot())); connect(this->ui->pb,SIGNAL(clicked()),this,SLOT(changeLabel())); } void Widget::changeLabel(){ newlabel->setText(this->foo); } and customWidget: class customWidget : public QWidget { Q_OBJECT public: customWidget(); QPushButton *customPB; public slots: void callParentSlot(); }; customWidget::customWidget() { customPB = new QPushButton("customPB"); QHBoxLayout *hboxl = new QHBoxLayout(); hboxl->addWidget(customPB); this->setLayout(hboxl); connect(this->customPB,SIGNAL(clicked()),this,SLOT(callParentSlot())); } void customWidget::callParentSlot(){ ((Widget*)this->parentWidget())->changeLabel(); } in the main function, I simply created an instance of Widget, and called show() on it. This Widget instance has a label, a QString, an instance of customWidget class, and two buttons (inside the ui class, pushButton and pb). One of the buttons calls a slot in its own class called changeLabel(), that, as the name suggests, changes the label to whatever is set in the QString contained in it. I made that just to check that changeLabel() worked. This button is working fine. The other button calls a slot in the customWidget instance, named callParentSlot(), that in turn tries to call the changeLabel() slot in its parent. Since in this case I know that its parent is in fact an instance of Widget, I cast the return value of parentWidget() to Widget*. This button crashes the program. I made a button within customWidget to try to call customWidget's parent slot as well, but it also crashes the program. I followed what was on this question. What am I missing?

    Read the article

  • How to get the selectionchange event in Qt

    - by Solitaire
    Hi.. I have a class inherited from Qwidget, now in that class I will be creating "Qlistview" object and filling up the items to view.. When the selection of items in the listview gets changed I want to get the "selectionchange" event to come.. So how can I achieve this.. pls tell me in brief... thanks

    Read the article

  • kill process without knowing the full path using QT

    - by kaycee
    i'm trying to retrieve the active processes on my computer and to search for specific one, if it exists then i should kill it. is it possible to do it without knowing the specific path of the execute ? i know the execute process name but not the full path. so in short: 1. get all active processes 2. kill specific process thanks !

    Read the article

  • how to convert unicode to printable string in QT stream

    - by user63898
    I'm writing a stream to a file and stdout, but I'm getting some kind of encoding like this: \u05ea\u05e7\u05dc\u05d9\u05d8 \u05e9\u05e1\u05d9\u05de\u05dc \u05e9\u05d9\u05e0\u05d5\u05d9 \u05d1\u05e1\u05d2\u05e0\u05d5\u05df \u05dc\u05d3\u05e2\u05ea\u05d9 \u05d0\u05dd \u05d0\u05e0\u05d9 \u05d6\u05d5\u05db\u05e8 \u05e0\u05db\u05d5\u05df How can I convert this to a printable string?

    Read the article

  • My listview is not gaining the keyboard focus in Qt

    - by Solitaire
    Hi, i am trying to operate the listview itesm through keyboard focus, its not moving.. can you folks suggest where i am wrong. if i click on the listview from mouse, listview is gaining the focus. i dont no what is wrong. #include <QtGui> #include <QApplication> class Newlist : public QListView { public: Newlist(QWidget *parent = 0); ~Newlist(){}; public: QListView *list; QStringListModel *model; }; Newlist::Newlist(QWidget *parent) : QListView(parent) { list = new QListView(this); list->setViewMode(QListView::ListMode); list->setSelectionMode(QAbstractItemView::SingleSelection); list->setMinimumSize(300,500); model = new QStringListModel(this); QStringList strlist; strlist<<"Test"<<"fest"<<"mest"; list->setModel(model); model->setStringList(strlist); QModelIndex index = model->index(1,0); list->setCurrentIndex(index); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(list); setLayout(layout); list->setFocus(); } class Test : public QMainWindow { public: Test(QWidget *parent = 0); ~Test(){}; private: Mylistview *newlist; QVBoxLayout *layout; }; Test::Test(QWidget *parent) : QMainWindow(parent) { layout = new QVBoxLayout(); newlist = new Mylistview(); this->setCentralWidget(newlist); } int main(int argc, char *argv[]) { QApplication a(argc, argv); Test test; test.showMaximized(); return a.exec(); } Thanks in advance

    Read the article

  • Qt - reading from a text file

    - by user289175
    Hello world, I have a table view with three columns; I have just passed to write into text file using this code QFile file("/home/hamad/lesson11.txt"); if(!file.open(QIODevice::WriteOnly)) { QMessageBox::information(0,"error",file.errorString()); } QString dd; for(int row=0; row < model->rowCount(); row++) { dd = model->item(row,0)->text() + "," + model->item(row,1)->text() + "," + model->item(row,2)->text(); QTextStream out(&file); out << dd << endl; } But I'm not succeed to read the same file again, I tried this code but I don't know where is the problem in it QFile file("/home/hamad/lesson11.txt"); QTextStream in(&file); QString line = in.readLine(); while(!in.atEnd()) { QStringList fields = line.split(","); model->appendRow(fields); } Any help please ?

    Read the article

  • Qt Qbrush issue

    - by Solitaire
    What is the difference in the following code, QGraphicsScene * scence = new QGraphicsScene(); QBrush *brush = new QBrush((QColor(60,20,20))); scence->setBackgroundBrush(*brush); QGraphicsView *view = new QGraphicsView(); view->setScene(scence); //view->setBackgroundBrush(*brush); //view->setCacheMode(QGraphicsView::CacheBackground); view->showFullScreen(); gives black color background QGraphicsScene * scence = new QGraphicsScene(); QBrush *brush = new QBrush(); brush->setColor(QColor(60,20,20)); scence->setBackgroundBrush(*brush); QGraphicsView *view = new QGraphicsView(); view->setScene(scence); //view->setBackgroundBrush(*brush); //view->setCacheMode(QGraphicsView::CacheBackground); view->showFullScreen(); it gives nothing.

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >